public String toString(@Nullable Object value) { if (value == null) { return ""; } checkValue(value); String string = value.toString(); string = escapesValue ? escapeSingle(string) : string; string = quotesValue ? singleQuote(string) : string; return string; }
CqlStringUtils.escapeSingle(key), CqlStringUtils.escapeSingle(value))));
/** * Adds the given option by name to this table's options. * <p/> * Options that have {@literal null} values are considered single string options where the name of the option is the * string to be used. Otherwise, the result of {@link Object#toString()} is considered to be the value of the option * with the given name. The value, after conversion to string, may have embedded single quotes escaped according to * parameter {@code escape} and may be single-quoted according to parameter <code>quote</code>. * * @param name The name of the option * @param value The value of the option. If {@literal null}, the value is ignored and the option is considered to be * composed of only the name, otherwise the value's {@link Object#toString()} value is used. * @param escape Whether to escape the value via {@link CqlStringUtils#escapeSingle(Object)}. Ignored if given value * is an instance of a {@link Map}. * @param quote Whether to quote the value via {@link CqlStringUtils#singleQuote(Object)}. Ignored if given value is * an instance of a {@link Map}. * @return this */ @SuppressWarnings("unchecked") public T with(String name, @Nullable Object value, boolean escape, boolean quote) { if (!(value instanceof Map)) { if (escape) { value = escapeSingle(value); } if (quote) { value = singleQuote(value); } } this.options.put(name, value); return (T) this; }
/** * Adds the given option by name to this keyspaces's options. * <p/> * Options that have {@literal null} values are considered single string options where the name of the option is the * string to be used. Otherwise, the result of {@link Object#toString()} is considered to be the value of the option * with the given name. The value, after conversion to string, may have embedded single quotes escaped according to * parameter {@code escape} and may be single-quoted according to parameter <code>quote</code>. * * @param name The name of the option * @param value The value of the option. If {@literal null}, the value is ignored and the option is considered to be * composed of only the name, otherwise the value's {@link Object#toString()} value is used. * @param escape Whether to escape the value via {@link CqlStringUtils#escapeSingle(Object)}. Ignored if given value * is an instance of a {@link Map}. * @param quote Whether to quote the value via {@link CqlStringUtils#singleQuote(Object)}. Ignored if given value is * an instance of a {@link Map}. * @return this */ @SuppressWarnings("unchecked") public T with(String name, @Nullable Object value, boolean escape, boolean quote) { if (!(value instanceof Map)) { if (escape) { value = escapeSingle(value); } if (quote) { value = singleQuote(value); } } options.put(name, value); return (T) this; }
cql.append(singleQuote(option.getName())); // entries in map keys are always quoted cql.append(" : "); Object entryValue = entry.getValue(); entryValue = entryValue == null ? "" : entryValue.toString(); if (option.escapesValue()) { entryValue = escapeSingle(entryValue); entryValue = singleQuote(entryValue);