/** * Read a string. * * @return the value */ @Override public String readString() throws IOException { int len = in.readInt(); if (len == -1) { return null; } StringBuilder buff = new StringBuilder(len); for (int i = 0; i < len; i++) { buff.append(in.readChar()); } String s = buff.toString(); s = StringUtils.cache(s); return s; }
/** * Get or create a string value for the given string. * * @param s the string * @return the value */ public static ValueString get(String s) { if (s.length() == 0) { return EMPTY; } ValueString obj = new ValueString(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueString) Value.cache(obj); // this saves memory, but is really slow // return new ValueString(s.intern()); }
/** * Get or create a string value for the given string. * * @param s the string * @param treatEmptyStringsAsNull whether or not to treat empty strings as * NULL * @return the value */ public static Value get(String s, boolean treatEmptyStringsAsNull) { if (s.isEmpty()) { return treatEmptyStringsAsNull ? ValueNull.INSTANCE : EMPTY; } ValueString obj = new ValueString(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return Value.cache(obj); // this saves memory, but is really slow // return new ValueString(s.intern()); }
/** * Get or create a case insensitive string value for the given string. * The value will have the same case as the passed string. * * @param s the string * @return the value */ public static ValueStringIgnoreCase get(String s) { if (s.length() == 0) { return EMPTY; } ValueStringIgnoreCase obj = new ValueStringIgnoreCase(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } ValueStringIgnoreCase cache = (ValueStringIgnoreCase) Value.cache(obj); // the cached object could have the wrong case // (it would still be 'equal', but we don't like to store it) if (cache.value.equals(s)) { return cache; } return obj; }
/** * Get or create a fixed length string value for the given string. * Spaces at the end of the string will be removed. * * @param s the string * @return the value */ public static ValueStringFixed get(String s) { s = trimRight(s); if (s.length() == 0) { return EMPTY; } ValueStringFixed obj = new ValueStringFixed(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueStringFixed) Value.cache(obj); }
currentToken = StringUtils.cache(sqlCommand.substring(start, i)); currentTokenType = getTokenType(currentToken); parseIndex = i; currentToken = StringUtils.cache(result); parseIndex = i; currentTokenQuoted = true; currentValue = ValueString.get(StringUtils.cache(result), database.getMode().treatEmptyStringsAsNull); parseIndex = i; currentTokenType = VALUE; currentToken = "'"; checkLiterals(true); currentValue = ValueString.get(StringUtils.cache(result), database.getMode().treatEmptyStringsAsNull); parseIndex = i; currentTokenType = VALUE;
command.setColumnNames(cols); String select = StringUtils.cache(sqlCommand.substring(parseIndex)); read("AS"); try {
read(")"); withQuery.prepare(); querySQL = StringUtils.cache(withQuery.getPlanSQL()); } finally { session.removeLocalTempTable(recursiveTable);