/** * 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. 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. 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. 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. 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. 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 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. 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 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 * 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 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 * 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 * BigInteger 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 BigInteger) { return result; } if (result instanceof Number) { return BigInteger.valueOf(((Number)result).longValue()); } try { return new BigInteger(result.toString()); } catch (final NumberFormatException ex) { throw new ConversionException("Suplied number is not of type BigInteger: " + result); } }
/** * Convert the specified locale-sensitive input object into an output object of * BigInteger 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 BigInteger) { return result; } if (result instanceof Number) { return BigInteger.valueOf(((Number)result).longValue()); } try { return new BigInteger(result.toString()); } catch (final NumberFormatException ex) { throw new ConversionException("Suplied number is not of type BigInteger: " + result); } }
/** * 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 */ protected Object parse(Object value, String pattern) throws ParseException { 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. 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 * * @exception ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ protected Object parse(Object value, 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 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 * * @exception org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ protected Object parse(Object value, 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. 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 * * @exception ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ protected Object parse(Object value, 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 } }