/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Timestamp(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Double type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number result = (Number) super.parse(value, pattern); if (result instanceof Long) { return new Double(result.doubleValue()); } else { return (result); } }
converter.put(BigDecimal.class, new BigDecimalLocaleConverter(locale, applyLocalized)); converter.put(BigInteger.class, new BigIntegerLocaleConverter(locale, applyLocalized)); converter.put(Byte.class, new ByteLocaleConverter(locale, applyLocalized)); converter.put(Byte.TYPE, new ByteLocaleConverter(locale, applyLocalized)); converter.put(Double.class, new DoubleLocaleConverter(locale, applyLocalized)); converter.put(Double.TYPE, new DoubleLocaleConverter(locale, applyLocalized)); converter.put(Float.class, new FloatLocaleConverter(locale, applyLocalized)); converter.put(Float.TYPE, new FloatLocaleConverter(locale, applyLocalized)); converter.put(Integer.class, new IntegerLocaleConverter(locale, applyLocalized)); converter.put(Integer.TYPE, new IntegerLocaleConverter(locale, applyLocalized)); converter.put(Long.class, new LongLocaleConverter(locale, applyLocalized)); converter.put(Long.TYPE, new LongLocaleConverter(locale, applyLocalized)); converter.put(Short.class, new ShortLocaleConverter(locale, applyLocalized)); converter.put(Short.TYPE, new ShortLocaleConverter(locale, applyLocalized)); converter.put(String.class, new StringLocaleConverter(locale, applyLocalized)); converter.put(java.sql.Date.class, new SqlDateLocaleConverter(locale, "yyyy-MM-dd")); converter.put(java.sql.Time.class, new SqlTimeLocaleConverter(locale, "HH:mm:ss")); converter.put( java.sql.Timestamp.class, new SqlTimestampLocaleConverter(locale, "yyyy-MM-dd HH:mm:ss.S") );
converter.put(BigDecimal.class, new BigDecimalLocaleConverter(locale, applyLocalized)); converter.put(BigInteger.class, new BigIntegerLocaleConverter(locale, applyLocalized)); converter.put(Byte.class, new ByteLocaleConverter(locale, applyLocalized)); converter.put(Byte.TYPE, new ByteLocaleConverter(locale, applyLocalized)); converter.put(Double.class, new DoubleLocaleConverter(locale, applyLocalized)); converter.put(Double.TYPE, new DoubleLocaleConverter(locale, applyLocalized)); converter.put(Float.class, new FloatLocaleConverter(locale, applyLocalized)); converter.put(Float.TYPE, new FloatLocaleConverter(locale, applyLocalized)); converter.put(Integer.class, new IntegerLocaleConverter(locale, applyLocalized)); converter.put(Integer.TYPE, new IntegerLocaleConverter(locale, applyLocalized)); converter.put(Long.class, new LongLocaleConverter(locale, applyLocalized)); converter.put(Long.TYPE, new LongLocaleConverter(locale, applyLocalized)); converter.put(Short.class, new ShortLocaleConverter(locale, applyLocalized)); converter.put(Short.TYPE, new ShortLocaleConverter(locale, applyLocalized)); converter.put(String.class, new StringLocaleConverter(locale, applyLocalized)); converter.put(java.sql.Date.class, new SqlDateLocaleConverter(locale, "yyyy-MM-dd")); converter.put(java.sql.Time.class, new SqlTimeLocaleConverter(locale, "HH:mm:ss")); converter.put( java.sql.Timestamp.class, new SqlTimestampLocaleConverter(locale, "yyyy-MM-dd HH:mm:ss.S") );
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Double type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number result = (Number) super.parse(value, pattern); if (result instanceof Long) { return new Double(result.doubleValue()); } else { return (result); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Date(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return a Long type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number * @since 1.8.0 */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Object result = super.parse(value, pattern); if (result == null || result instanceof Long) { return result; } return new Long(((Number)result).longValue()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Time(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return a Long type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number * @since 1.8.0 */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Object result = super.parse(value, pattern); if (result == null || result instanceof Long) { return result; } return new Long(((Number)result).longValue()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Date(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return values of type Byte. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); if (parsed.longValue() != parsed.byteValue()) { throw new ConversionException("Supplied number is not of type Byte: " + parsed.longValue()); } // now returns property Byte return new Byte(parsed.byteValue()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Timestamp(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Integer type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); if (parsed.longValue() != parsed.intValue()) { throw new ConversionException("Suplied number is not of type Integer: " + parsed.longValue()); } return new Integer(parsed.intValue()); // unlike superclass it will return proper Integer } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion * cannot be performed successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { return new Time(((java.util.Date) super.parse(value, pattern)).getTime()); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return values of type Byte. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); if (parsed.longValue() != parsed.byteValue()) { throw new ConversionException("Supplied number is not of type Byte: " + parsed.longValue()); } // now returns property Byte return new Byte(parsed.byteValue()); } }
/** * Convert the specified locale-sensitive input object into an output object of * BigDecimal type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number * @since 1.8.0 */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Object result = super.parse(value, pattern); if (result == null || result instanceof BigDecimal) { return result; } try { return new BigDecimal(result.toString()); } catch (final NumberFormatException ex) { throw new ConversionException("Suplied number is not of type BigDecimal: " + result); } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return values of type Short. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number * @since 1.8.0 */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Object result = super.parse(value, pattern); if (result == null || result instanceof Short) { return result; } final Number parsed = (Number)result; if (parsed.longValue() != parsed.shortValue()) { throw new ConversionException("Supplied number is not of type Short: " + parsed.longValue()); } // now returns property Short return new Short(parsed.shortValue()); }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Integer type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); if (parsed.longValue() != parsed.intValue()) { throw new ConversionException("Suplied number is not of type Integer: " + parsed.longValue()); } return new Integer(parsed.intValue()); // unlike superclass it will return proper Integer } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Float value or throw exception if value * can not be stored in the Float. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); final double doubleValue = parsed.doubleValue(); final double posDouble = (doubleValue >= 0) ? doubleValue : (doubleValue * -1); if (posDouble != 0 && (posDouble < Float.MIN_VALUE || posDouble > Float.MAX_VALUE)) { throw new ConversionException("Supplied number is not of type Float: "+parsed); } return new Float(parsed.floatValue()); // unlike superclass it returns Float type } }
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return values of type Short. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value * * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number * @since 1.8.0 */ @Override protected Object parse(final Object value, final String pattern) throws ParseException { final Object result = super.parse(value, pattern); if (result == null || result instanceof Short) { return result; } final Number parsed = (Number)result; if (parsed.longValue() != parsed.shortValue()) { throw new ConversionException("Supplied number is not of type Short: " + parsed.longValue()); } // now returns property Short return new Short(parsed.shortValue()); }