本文整理汇总了Java中jodd.util.StringUtil.startsWithChar方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.startsWithChar方法的具体用法?Java StringUtil.startsWithChar怎么用?Java StringUtil.startsWithChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jodd.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.startsWithChar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Float convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Float.class) {
return (Float) value;
}
if (value instanceof Number) {
return Float.valueOf(((Number)value).floatValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Float.valueOf(1) : Float.valueOf(0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Float.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例2: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Integer convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Integer.class) {
return (Integer) value;
}
if (value instanceof Number) {
return Integer.valueOf(((Number)value).intValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Integer.valueOf(1) : Integer.valueOf(0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Integer.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例3: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Double convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Double.class) {
return (Double) value;
}
if (value instanceof Number) {
return Double.valueOf(((Number)value).doubleValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Double.valueOf(1) : Double.valueOf(0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Double.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例4: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Byte convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Byte.class) {
return (Byte) value;
}
if (value instanceof Number) {
return Byte.valueOf(((Number)value).byteValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Byte.valueOf((byte) 1) : Byte.valueOf((byte) 0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Byte.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例5: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Short convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Short.class) {
return (Short) value;
}
if (value instanceof Number) {
return Short.valueOf(((Number)value).shortValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Short.valueOf((short) 1) : Short.valueOf((short) 0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Short.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例6: convert
import jodd.util.StringUtil; //导入方法依赖的package包/类
public Long convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Long.class) {
return (Long) value;
}
if (value instanceof Number) {
return Long.valueOf(((Number)value).longValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Long.valueOf(1L) : Long.valueOf(0L);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Long.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例7: resolve
import jodd.util.StringUtil; //导入方法依赖的package包/类
/**
* Resolves subpath in safer way. For some reason, if child starts with
* a separator it gets resolved as a full path, ignoring the base.
* This method acts different.
*/
public static Path resolve(Path base, String child) {
if (StringUtil.startsWithChar(child, File.separatorChar)) {
child = child.substring(1);
}
return base.resolve(child);
}
示例8: parseExpression
import jodd.util.StringUtil; //导入方法依赖的package包/类
@Override
public String parseExpression(String expression) {
if (StringUtil.startsWithChar(expression, '\'') || StringUtil.startsWithChar(expression, '"')) {
expression = expression.substring(1, expression.length() - 1);
}
return expression;
}
示例9: parseExpression
import jodd.util.StringUtil; //导入方法依赖的package包/类
@Override
public String parseExpression(String expression) {
if (StringUtil.startsWithChar(expression, '\'') || StringUtil.startsWithChar(expression, '"')) {
expression = expression.substring(1, expression.length() - 1);
}
return expression;
}