本文整理汇总了Java中org.h2.util.StringUtils.cache方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.cache方法的具体用法?Java StringUtils.cache怎么用?Java StringUtils.cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.cache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* 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);
}
示例2: readString
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* Read a string.
*
* @return the value
*/
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;
}
示例3: get
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* 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());
}
示例4: tokenize
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private String[] tokenize() {
ArrayList<String> list = New.arrayList();
syntax = StringUtils.replaceAll(syntax, "yyyy-MM-dd", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "hh:mm:ss", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "nnnnnnnnn", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "function", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "0x", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, ",...", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "...", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "||", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "a-z|_", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "A-Z|_", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "A-F", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "0-9", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "'['", "@[email protected]");
syntax = StringUtils.replaceAll(syntax, "']'", "@[email protected]");
StringTokenizer tokenizer = getTokenizer(syntax);
while (tokenizer.hasMoreTokens()) {
String s = tokenizer.nextToken();
// avoid duplicate strings
s = StringUtils.cache(s);
if (s.length() == 1) {
if (" \r\n".indexOf(s.charAt(0)) >= 0) {
continue;
}
}
list.add(s);
}
return list.toArray(new String[list.size()]);
}