@Override public Object convertValue(Map<String, Object> context, Object target, Member member, String propertyName, Object value, Class toType) { Object result; if (toType == String.class && (value instanceof Double || value instanceof Integer)) { result = convertToString(value); } else if (value instanceof String && (toType == Double.class || toType == double.class || toType == Integer.class || toType == int.class)) { result = convertToNumber((String) value, toType); } else { result = super.convertValue(context, target, member, propertyName, value, toType); } return result; }
Object convertedValue = super.convertValue(context, value, toType); String stringValue = (String) value; if (!isInRange((Number) convertedValue, stringValue, toType)) throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName()); return null; NumberFormat numFormat = NumberFormat.getInstance(getLocale(context)); ParsePosition parsePos = new ParsePosition(0); if (isIntegerType(toType)) { numFormat.setParseIntegerOnly(true); + parsePos.getIndex()); } else { if (!isInRange(number, stringValue, toType)) throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName()); return convertValue(context, null, null, null, objArray[0], toType);