本文整理汇总了Java中org.febit.convert.Convert类的典型用法代码示例。如果您正苦于以下问题:Java Convert类的具体用法?Java Convert怎么用?Java Convert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Convert类属于org.febit.convert包,在下文中一共展示了Convert类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.febit.convert.Convert; //导入依赖的package包/类
public Object invoke(OutgoingMessage msg) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
String text = msg.getFixedText();
String[] values = macros != null
? macros.exactExtract(text)
: null;
Object[] args = new Object[paramTypes.length];
for (int i = 0; i < args.length; i++) {
int index = paramIndexer[i];
switch (index) {
case -1:
args[i] = null;
break;
case -2:
args[i] = msg;
break;
default:
if (index >= 0) {
args[i] = Convert.convert(values[index], paramTypes[i]);
break;
}
throw new IllegalStateException("Unsupported index: " + index);
}
}
return method.invoke(action, args);
}
示例2: convert
import org.febit.convert.Convert; //导入依赖的package包/类
protected <T> T convert(String string, Class<T> cls) {
return Convert.convert(string, cls, defaultConverter);
}
示例3: getInt
import org.febit.convert.Convert; //导入依赖的package包/类
public int getInt(String key) {
return Convert.toInt(get(key));
}
示例4: resolve
import org.febit.convert.Convert; //导入依赖的package包/类
@Override
public Object resolve(ActionRequest request, Class type, String name, int index) {
final String raw = request.getParameter(name);
if (type == String.class) {
return raw;
}
if (type == int.class) {
if (raw == null || raw.length() == 0) {
return 0;
}
return Convert.toInt(raw);
}
if (type == long.class) {
if (raw == null || raw.length() == 0) {
return 0;
}
return Convert.toLong(raw);
}
if (type == boolean.class) {
return Convert.toBool(raw);
}
if (raw == null) {
return null;
}
if (type == Boolean.class) {
return Convert.toBool(raw);
}
if (raw.length() == 0) {
return null;
}
if (type == Integer.class) {
return Convert.toInt(raw);
}
if (type == Long.class) {
return Convert.toLong(raw);
}
return null;
}
示例5: set
import org.febit.convert.Convert; //导入依赖的package包/类
public static void set(final Object bean, final String name, Object value, boolean convertIfNeed) throws BeanUtilException {
Setter setter = getAccessor(bean.getClass(), name).setter;
if (setter == null) {
throw new BeanUtilException(StringUtil.format("Unable to get setter for {}#{}", bean.getClass(), name));
}
if (convertIfNeed && (value == null || value instanceof String)) {
value = Convert.convert((String) value, setter.getPropertyType());
}
setter.set(bean, value);
}
示例6: getIntIds
import org.febit.convert.Convert; //导入依赖的package包/类
public int[] getIntIds() {
if (StringUtil.isEmpty(ids)) {
return null;
}
return Convert.toIntArray(ids);
}
示例7: getLongIds
import org.febit.convert.Convert; //导入依赖的package包/类
public long[] getLongIds() {
if (StringUtil.isEmpty(ids)) {
return null;
}
return Convert.toLongArray(ids);
}
示例8: getStringIds
import org.febit.convert.Convert; //导入依赖的package包/类
public String[] getStringIds() {
if (StringUtil.isEmpty(ids)) {
return null;
}
return Convert.toStringArray(ids);
}
示例9: getBool
import org.febit.convert.Convert; //导入依赖的package包/类
public boolean getBool(String key) {
return Convert.toBool(get(key));
}