本文整理汇总了Java中jodd.util.StringUtil.count方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.count方法的具体用法?Java StringUtil.count怎么用?Java StringUtil.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jodd.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareArrayClassnameForLoading
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* Prepares classname for loading, respecting the arrays.
* Returns <code>null</code> if class name is not an array.
*/
public static String prepareArrayClassnameForLoading(String className) {
int bracketCount = StringUtil.count(className, '[');
if (bracketCount == 0) {
// not an array
return null;
}
String brackets = StringUtil.repeat('[', bracketCount);
int bracketIndex = className.indexOf('[');
className = className.substring(0, bracketIndex);
int primitiveNdx = getPrimitiveClassNameIndex(className);
if (primitiveNdx >= 0) {
className = String.valueOf(PRIMITIVE_BYTECODE_NAME[primitiveNdx]);
return brackets + className;
} else {
return brackets + 'L' + className + ';';
}
}
示例2: loadArrayClassByComponentType
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* Loads array class using component type.
*/
protected Class loadArrayClassByComponentType(String className, ClassLoader classLoader) throws ClassNotFoundException {
int ndx = className.indexOf('[');
int multi = StringUtil.count(className, '[');
String componentTypeName = className.substring(0, ndx);
Class componentType = loadClass(componentTypeName, classLoader);
if (multi == 1) {
return Array.newInstance(componentType, 0).getClass();
}
int[] multiSizes;
if (multi == 2) {
multiSizes = new int[] {0, 0};
} else if (multi == 3) {
multiSizes = new int[] {0, 0, 0};
} else {
multiSizes = (int[]) Array.newInstance(int.class, multi);
}
return Array.newInstance(componentType, multiSizes).getClass();
}
示例3: prepareArrayClassnameForLoading
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* Prepares classname for loading, respecting the arrays.
* Returns <code>null</code> if class name is not an array.
*/
public static String prepareArrayClassnameForLoading(String className) {
int bracketCount = StringUtil.count(className, '[');
if (bracketCount == 0) {
// not an array
return null;
}
String brackets = StringUtil.repeat('[', bracketCount);
int bracketIndex = className.indexOf('[');
className = className.substring(0, bracketIndex);
int primitiveNdx = getPrimitiveClassNameIndex(className);
if (primitiveNdx >= 0) {
className = String.valueOf(PRIMITIVE_BYTECODE_NAME[primitiveNdx]);
return brackets + className;
} else {
return brackets + 'L' + className + ';';
}
}
示例4: loadArrayClassByComponentType
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* Loads array class using component type.
*/
protected Class loadArrayClassByComponentType(String className, ClassLoader classLoader) throws ClassNotFoundException {
int ndx = className.indexOf('[');
int multi = StringUtil.count(className, '[');
String componentTypeName = className.substring(0, ndx);
Class componentType = loadClass(componentTypeName, classLoader);
if (multi == 1) {
return Array.newInstance(componentType, 0).getClass();
}
int[] multiSizes;
if (multi == 2) {
multiSizes = new int[]{0, 0};
} else if (multi == 3) {
multiSizes = new int[]{0, 0, 0};
} else {
multiSizes = (int[]) Array.newInstance(int.class, multi);
}
return Array.newInstance(componentType, multiSizes).getClass();
}
示例5: init
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean init(final String actionPath, String[] separators) {
String prefix = separators[0];
String split = separators[1];
String suffix = separators[2];
macrosCount = StringUtil.count(actionPath, prefix);
if (macrosCount == 0) {
return false;
}
names = new String[macrosCount];
patterns = new String[macrosCount];
fixed = new String[macrosCount + 1];
int offset = 0;
int i = 0;
while (true) {
int[] ndx = StringUtil.indexOfRegion(actionPath, prefix, suffix, offset);
if (ndx == null) {
break;
}
fixed[i] = actionPath.substring(offset, ndx[0]);
String name = actionPath.substring(ndx[1], ndx[2]);
// name:pattern
String pattern = null;
int colonNdx = name.indexOf(split);
if (colonNdx != -1) {
pattern = name.substring(colonNdx + 1).trim();
name = name.substring(0, colonNdx).trim();
}
this.patterns[i] = pattern;
this.names[i] = name;
// iterate
offset = ndx[3];
i++;
}
if (offset < actionPath.length()) {
fixed[i] = actionPath.substring(offset);
} else {
fixed[i] = StringPool.EMPTY;
}
return true;
}