/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ @Deprecated public void setDefaultShort(final short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
@SuppressWarnings("rawtypes") public Object convert(Class destClass, Object srcObj) { // Boolean to Int not supported in apache common's int converter and this is why this class is req'd if (Boolean.class.isAssignableFrom(srcObj.getClass())) { boolean value = (Boolean)srcObj; return value ? (short)1 : (short)0; } else if (MappingUtils.isEnumType(srcObj.getClass())) { return ((Integer)((Enum)srcObj).ordinal()).shortValue(); } else { return commonsConverter.convert(destClass, srcObj); } } }
/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ @Deprecated public void setDefaultShort(final short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
@SuppressWarnings("rawtypes") public Object convert(Class destClass, Object srcObj) { // Boolean to Int not supported in apache common's int converter and this is why this class is req'd if (Boolean.class.isAssignableFrom(srcObj.getClass())) { boolean value = (Boolean)srcObj; return value ? (short)1 : (short)0; } else if (MappingUtils.isEnumType(srcObj.getClass())) { return ((Integer)((Enum)srcObj).ordinal()).shortValue(); } else { return commonsConverter.convert(destClass, srcObj); } } }
/** * Register the converters for primitive types. * </p> * This method registers the following converters: * <ul> * <li><code>Boolean.TYPE</code> - {@link BooleanConverter}</li> * <li><code>Byte.TYPE</code> - {@link ByteConverter}</li> * <li><code>Character.TYPE</code> - {@link CharacterConverter}</li> * <li><code>Double.TYPE</code> - {@link DoubleConverter}</li> * <li><code>Float.TYPE</code> - {@link FloatConverter}</li> * <li><code>Integer.TYPE</code> - {@link IntegerConverter}</li> * <li><code>Long.TYPE</code> - {@link LongConverter}</li> * <li><code>Short.TYPE</code> - {@link ShortConverter}</li> * </ul> * @param throwException <code>true</code> if the converters should * throw an exception when a conversion error occurs, otherwise <code> * <code>false</code> if a default value should be used. */ private void registerPrimitives(final boolean throwException) { register(Boolean.TYPE, throwException ? new BooleanConverter() : new BooleanConverter(Boolean.FALSE)); register(Byte.TYPE, throwException ? new ByteConverter() : new ByteConverter(ZERO)); register(Character.TYPE, throwException ? new CharacterConverter() : new CharacterConverter(SPACE)); register(Double.TYPE, throwException ? new DoubleConverter() : new DoubleConverter(ZERO)); register(Float.TYPE, throwException ? new FloatConverter() : new FloatConverter(ZERO)); register(Integer.TYPE, throwException ? new IntegerConverter() : new IntegerConverter(ZERO)); register(Long.TYPE, throwException ? new LongConverter() : new LongConverter(ZERO)); register(Short.TYPE, throwException ? new ShortConverter() : new ShortConverter(ZERO)); }
@SuppressWarnings("rawtypes") public Object convert(Class destClass, Object srcObj) { // Boolean to Int not supported in apache common's int converter and this is why this class is req'd if (Boolean.class.isAssignableFrom(srcObj.getClass())) { boolean value = (Boolean) srcObj; return (value ? (short) 1 : (short) 0); } else if (MappingUtils.isEnumType(srcObj.getClass())) { return ((Integer) ((Enum) srcObj).ordinal()).shortValue(); } else { return commonsConverter.convert(destClass, srcObj); } }
/** * Register the converters for primitive types. * </p> * This method registers the following converters: * <ul> * <li><code>Boolean.TYPE</code> - {@link BooleanConverter}</li> * <li><code>Byte.TYPE</code> - {@link ByteConverter}</li> * <li><code>Character.TYPE</code> - {@link CharacterConverter}</li> * <li><code>Double.TYPE</code> - {@link DoubleConverter}</li> * <li><code>Float.TYPE</code> - {@link FloatConverter}</li> * <li><code>Integer.TYPE</code> - {@link IntegerConverter}</li> * <li><code>Long.TYPE</code> - {@link LongConverter}</li> * <li><code>Short.TYPE</code> - {@link ShortConverter}</li> * </ul> * @param throwException <code>true</code> if the converters should * throw an exception when a conversion error occurs, otherwise <code> * <code>false</code> if a default value should be used. */ private void registerPrimitives(final boolean throwException) { register(Boolean.TYPE, throwException ? new BooleanConverter() : new BooleanConverter(Boolean.FALSE)); register(Byte.TYPE, throwException ? new ByteConverter() : new ByteConverter(ZERO)); register(Character.TYPE, throwException ? new CharacterConverter() : new CharacterConverter(SPACE)); register(Double.TYPE, throwException ? new DoubleConverter() : new DoubleConverter(ZERO)); register(Float.TYPE, throwException ? new FloatConverter() : new FloatConverter(ZERO)); register(Integer.TYPE, throwException ? new IntegerConverter() : new IntegerConverter(ZERO)); register(Long.TYPE, throwException ? new LongConverter() : new LongConverter(ZERO)); register(Short.TYPE, throwException ? new ShortConverter() : new ShortConverter(ZERO)); }
register(Integer.class, throwException ? new IntegerConverter() : new IntegerConverter(defaultNumber)); register(Long.class, throwException ? new LongConverter() : new LongConverter(defaultNumber)); register(Short.class, throwException ? new ShortConverter() : new ShortConverter(defaultNumber)); register(String.class, throwException ? new StringConverter() : new StringConverter(stringDefault));
register(Integer.class, throwException ? new IntegerConverter() : new IntegerConverter(defaultNumber)); register(Long.class, throwException ? new LongConverter() : new LongConverter(defaultNumber)); register(Short.class, throwException ? new ShortConverter() : new ShortConverter(defaultNumber)); register(String.class, throwException ? new StringConverter() : new StringConverter(stringDefault));
cub.register(new ArrayConverter(long[].class, new LongConverter()), long[].class); cub.register(new ShortConverter(), Short.TYPE); cub.register(new ShortConverter(), Short.class); cub.register(new ArrayConverter(short[].class, new ShortConverter()), short[].class); cub.register(new RelaxedStringArrayConverter(), String[].class);
registerArrayConverter(Integer.TYPE, new IntegerConverter(), throwException, defaultArraySize); registerArrayConverter(Long.TYPE, new LongConverter(), throwException, defaultArraySize); registerArrayConverter(Short.TYPE, new ShortConverter(), throwException, defaultArraySize); registerArrayConverter(Integer.class, new IntegerConverter(), throwException, defaultArraySize); registerArrayConverter(Long.class, new LongConverter(), throwException, defaultArraySize); registerArrayConverter(Short.class, new ShortConverter(), throwException, defaultArraySize); registerArrayConverter(String.class, new StringConverter(), throwException, defaultArraySize);
registerArrayConverter(Integer.TYPE, new IntegerConverter(), throwException, defaultArraySize); registerArrayConverter(Long.TYPE, new LongConverter(), throwException, defaultArraySize); registerArrayConverter(Short.TYPE, new ShortConverter(), throwException, defaultArraySize); registerArrayConverter(Integer.class, new IntegerConverter(), throwException, defaultArraySize); registerArrayConverter(Long.class, new LongConverter(), throwException, defaultArraySize); registerArrayConverter(Short.class, new ShortConverter(), throwException, defaultArraySize); registerArrayConverter(String.class, new StringConverter(), throwException, defaultArraySize);
/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ public void setDefaultShort(short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ public void setDefaultShort(short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ public void setDefaultShort(short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
/** * Sets the default value for Short conversions. * @param newDefaultShort The default Short value * @deprecated Register replacement converters for Short.TYPE and * Short.class instead */ @Deprecated public void setDefaultShort(final short newDefaultShort) { defaultShort = new Short(newDefaultShort); register(new ShortConverter(defaultShort), Short.TYPE); register(new ShortConverter(defaultShort), Short.class); }
/** * Initializes the converters to behave the way we want when converting values (we don't * want empty strings converted to zeros, like beanutils does by default) */ private void initializeConverters() { ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new ShortConverter(null), Short.class); ConvertUtils.register(new CalendarConverter(), Calendar.class); ConvertUtils.register(new DateConverter(), Date.class); }
ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new ShortConverter(null), Short.class);
/** * Initializes the converters to behave the way we want when converting values (we don't * want empty strings converted to zeros, like beanutils does by default) */ private void initializeConverters() { ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new ShortConverter(null), Short.class); ConvertUtils.register(new CalendarConverter(), Calendar.class); ConvertUtils.register(new DateConverter(), Date.class); }
ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new ShortConverter(null), Short.class);