try {
return useType.getConstructor(new Class[] { boolean.class })
.newInstance(new Object[] { object });
}
catch (Exception e) {
throw new JXPathTypeConversionException(useType.getName(), e);
}
}
}
if (object instanceof Number) {
double value = ((Number) object).doubleValue();
if (useType == Boolean.class) {
return value == 0.0 ? Boolean.FALSE : Boolean.TRUE;
}
if (Number.class.isAssignableFrom(useType)) {
return allocateNumber(useType, value);
}
}
if (object instanceof String) {
Object value = convertStringToPrimitive(object, useType);
if (value != null) {
return value;
}
}
Converter converter = ConvertUtils.lookup(useType);
if (converter != null) {
return converter.convert(useType, object);
}
throw new JXPathTypeConversionException("Cannot convert "
+ object.getClass() + " to " + useType);
}