Search in sources :

Example 1 with LongArrayConverter

use of jodd.typeconverter.impl.LongArrayConverter in project jodd by oblac.

the class TypeConverterManagerBean method registerDefaults.

/**
	 * Registers default set of converters.
	 */
@SuppressWarnings({ "UnnecessaryFullyQualifiedName" })
public void registerDefaults() {
    register(String.class, new StringConverter());
    register(String[].class, new StringArrayConverter(this));
    IntegerConverter integerConverter = new IntegerConverter();
    register(Integer.class, integerConverter);
    register(int.class, integerConverter);
    register(MutableInteger.class, new MutableIntegerConverter(this));
    ShortConverter shortConverter = new ShortConverter();
    register(Short.class, shortConverter);
    register(short.class, shortConverter);
    register(MutableShort.class, new MutableShortConverter(this));
    LongConverter longConverter = new LongConverter();
    register(Long.class, longConverter);
    register(long.class, longConverter);
    register(MutableLong.class, new MutableLongConverter(this));
    ByteConverter byteConverter = new ByteConverter();
    register(Byte.class, byteConverter);
    register(byte.class, byteConverter);
    register(MutableByte.class, new MutableByteConverter(this));
    FloatConverter floatConverter = new FloatConverter();
    register(Float.class, floatConverter);
    register(float.class, floatConverter);
    register(MutableFloat.class, new MutableFloatConverter(this));
    DoubleConverter doubleConverter = new DoubleConverter();
    register(Double.class, doubleConverter);
    register(double.class, doubleConverter);
    register(MutableDouble.class, new MutableDoubleConverter(this));
    BooleanConverter booleanConverter = new BooleanConverter();
    register(Boolean.class, booleanConverter);
    register(boolean.class, booleanConverter);
    CharacterConverter characterConverter = new CharacterConverter();
    register(Character.class, characterConverter);
    register(char.class, characterConverter);
    register(byte[].class, new ByteArrayConverter(this));
    register(short[].class, new ShortArrayConverter(this));
    register(int[].class, new IntegerArrayConverter(this));
    register(long[].class, new LongArrayConverter(this));
    register(float[].class, new FloatArrayConverter(this));
    register(double[].class, new DoubleArrayConverter(this));
    register(boolean[].class, new BooleanArrayConverter(this));
    register(char[].class, new CharacterArrayConverter(this));
    // we don't really need these, but converters will be cached and not created every time
    register(Integer[].class, new ArrayConverter<Integer>(this, Integer.class) {

        @Override
        protected Integer[] createArray(int length) {
            return new Integer[length];
        }
    });
    register(Long[].class, new ArrayConverter<Long>(this, Long.class) {

        @Override
        protected Long[] createArray(int length) {
            return new Long[length];
        }
    });
    register(Byte[].class, new ArrayConverter<Byte>(this, Byte.class) {

        @Override
        protected Byte[] createArray(int length) {
            return new Byte[length];
        }
    });
    register(Short[].class, new ArrayConverter<Short>(this, Short.class) {

        @Override
        protected Short[] createArray(int length) {
            return new Short[length];
        }
    });
    register(Float[].class, new ArrayConverter<Float>(this, Float.class) {

        @Override
        protected Float[] createArray(int length) {
            return new Float[length];
        }
    });
    register(Double[].class, new ArrayConverter<Double>(this, Double.class) {

        @Override
        protected Double[] createArray(int length) {
            return new Double[length];
        }
    });
    register(Boolean[].class, new ArrayConverter<Boolean>(this, Boolean.class) {

        @Override
        protected Boolean[] createArray(int length) {
            return new Boolean[length];
        }
    });
    register(Character[].class, new ArrayConverter<Character>(this, Character.class) {

        @Override
        protected Character[] createArray(int length) {
            return new Character[length];
        }
    });
    register(MutableInteger[].class, new ArrayConverter<>(this, MutableInteger.class));
    register(MutableLong[].class, new ArrayConverter<>(this, MutableLong.class));
    register(MutableByte[].class, new ArrayConverter<>(this, MutableByte.class));
    register(MutableShort[].class, new ArrayConverter<>(this, MutableShort.class));
    register(MutableFloat[].class, new ArrayConverter<>(this, MutableFloat.class));
    register(MutableDouble[].class, new ArrayConverter<>(this, MutableDouble.class));
    register(BigDecimal.class, new BigDecimalConverter());
    register(BigInteger.class, new BigIntegerConverter());
    register(BigDecimal[].class, new ArrayConverter<>(this, BigDecimal.class));
    register(BigInteger[].class, new ArrayConverter<>(this, BigInteger.class));
    register(java.util.Date.class, new DateConverter());
    register(java.sql.Date.class, new SqlDateConverter());
    register(Time.class, new SqlTimeConverter());
    register(Timestamp.class, new SqlTimestampConverter());
    register(Calendar.class, new CalendarConverter());
    register(GregorianCalendar.class, new CalendarConverter());
    register(JDateTime.class, new JDateTimeConverter());
    register(File.class, new FileConverter());
    register(Class.class, new ClassConverter());
    register(Class[].class, new ClassArrayConverter(this));
    register(URI.class, new URIConverter());
    register(URL.class, new URLConverter());
    register(Locale.class, new LocaleConverter());
    register(TimeZone.class, new TimeZoneConverter());
}
Also used : BigDecimalConverter(jodd.typeconverter.impl.BigDecimalConverter) SqlDateConverter(jodd.typeconverter.impl.SqlDateConverter) ShortArrayConverter(jodd.typeconverter.impl.ShortArrayConverter) MutableDouble(jodd.mutable.MutableDouble) TimeZoneConverter(jodd.typeconverter.impl.TimeZoneConverter) MutableShort(jodd.mutable.MutableShort) CalendarConverter(jodd.typeconverter.impl.CalendarConverter) MutableDoubleConverter(jodd.typeconverter.impl.MutableDoubleConverter) LocaleConverter(jodd.typeconverter.impl.LocaleConverter) MutableFloat(jodd.mutable.MutableFloat) FloatArrayConverter(jodd.typeconverter.impl.FloatArrayConverter) MutableShort(jodd.mutable.MutableShort) SqlDateConverter(jodd.typeconverter.impl.SqlDateConverter) DateConverter(jodd.typeconverter.impl.DateConverter) MutableInteger(jodd.mutable.MutableInteger) ByteConverter(jodd.typeconverter.impl.ByteConverter) MutableByteConverter(jodd.typeconverter.impl.MutableByteConverter) LongArrayConverter(jodd.typeconverter.impl.LongArrayConverter) StringConverter(jodd.typeconverter.impl.StringConverter) BigIntegerConverter(jodd.typeconverter.impl.BigIntegerConverter) MutableDouble(jodd.mutable.MutableDouble) MutableIntegerConverter(jodd.typeconverter.impl.MutableIntegerConverter) IntegerConverter(jodd.typeconverter.impl.IntegerConverter) MutableIntegerConverter(jodd.typeconverter.impl.MutableIntegerConverter) BigIntegerConverter(jodd.typeconverter.impl.BigIntegerConverter) MutableFloat(jodd.mutable.MutableFloat) LongConverter(jodd.typeconverter.impl.LongConverter) MutableLongConverter(jodd.typeconverter.impl.MutableLongConverter) URLConverter(jodd.typeconverter.impl.URLConverter) MutableByte(jodd.mutable.MutableByte) MutableLong(jodd.mutable.MutableLong) BigInteger(java.math.BigInteger) BooleanArrayConverter(jodd.typeconverter.impl.BooleanArrayConverter) MutableFloatConverter(jodd.typeconverter.impl.MutableFloatConverter) FloatConverter(jodd.typeconverter.impl.FloatConverter) SqlTimeConverter(jodd.typeconverter.impl.SqlTimeConverter) ByteArrayConverter(jodd.typeconverter.impl.ByteArrayConverter) IntegerArrayConverter(jodd.typeconverter.impl.IntegerArrayConverter) MutableShortConverter(jodd.typeconverter.impl.MutableShortConverter) ShortConverter(jodd.typeconverter.impl.ShortConverter) DoubleConverter(jodd.typeconverter.impl.DoubleConverter) MutableDoubleConverter(jodd.typeconverter.impl.MutableDoubleConverter) MutableByteConverter(jodd.typeconverter.impl.MutableByteConverter) JDateTimeConverter(jodd.typeconverter.impl.JDateTimeConverter) StringArrayConverter(jodd.typeconverter.impl.StringArrayConverter) MutableFloatConverter(jodd.typeconverter.impl.MutableFloatConverter) FileConverter(jodd.typeconverter.impl.FileConverter) MutableShortConverter(jodd.typeconverter.impl.MutableShortConverter) MutableLongConverter(jodd.typeconverter.impl.MutableLongConverter) ClassConverter(jodd.typeconverter.impl.ClassConverter) MutableByte(jodd.mutable.MutableByte) ClassArrayConverter(jodd.typeconverter.impl.ClassArrayConverter) BooleanConverter(jodd.typeconverter.impl.BooleanConverter) BigDecimal(java.math.BigDecimal) CharacterConverter(jodd.typeconverter.impl.CharacterConverter) BigInteger(java.math.BigInteger) MutableInteger(jodd.mutable.MutableInteger) MutableLong(jodd.mutable.MutableLong) SqlTimestampConverter(jodd.typeconverter.impl.SqlTimestampConverter) CharacterArrayConverter(jodd.typeconverter.impl.CharacterArrayConverter) URIConverter(jodd.typeconverter.impl.URIConverter) DoubleArrayConverter(jodd.typeconverter.impl.DoubleArrayConverter)

Example 2 with LongArrayConverter

use of jodd.typeconverter.impl.LongArrayConverter in project jodd by oblac.

the class LongArrayConverterTest method testConversion.

@Test
public void testConversion() {
    LongArrayConverter longArrayConverter = (LongArrayConverter) TypeConverterManager.lookup(long[].class);
    assertNull(longArrayConverter.convert(null));
    assertEq(arrl(173), longArrayConverter.convert(Double.valueOf(173)));
    assertEq(arrl(173, 1022, 29929), longArrayConverter.convert(arrf(173, 1022, 29929)));
    assertEq(arrl(173, 1022, 29929), longArrayConverter.convert(arrd(173, 1022, 29929)));
    assertEq(arrl(173, 1022, 29929), longArrayConverter.convert(arri(173, 1022, 29929)));
    assertEq(arrl(173, 1022, 29929), longArrayConverter.convert(arrl(173, 1022, 29929)));
    assertEq(arrl(173, 1022), longArrayConverter.convert(arrs("173", "1022")));
    assertEq(arrl(173, 1022), longArrayConverter.convert(arro("173", Long.valueOf(1022))));
    assertEq(arrl(111, 777, 333), longArrayConverter.convert(arrs("111", "   777     ", "333")));
    assertEq(arrl(111, 777, 333), longArrayConverter.convert("111,  777,  333"));
}
Also used : LongArrayConverter(jodd.typeconverter.impl.LongArrayConverter) Test(org.junit.Test)

Aggregations

LongArrayConverter (jodd.typeconverter.impl.LongArrayConverter)2 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 MutableByte (jodd.mutable.MutableByte)1 MutableDouble (jodd.mutable.MutableDouble)1 MutableFloat (jodd.mutable.MutableFloat)1 MutableInteger (jodd.mutable.MutableInteger)1 MutableLong (jodd.mutable.MutableLong)1 MutableShort (jodd.mutable.MutableShort)1 BigDecimalConverter (jodd.typeconverter.impl.BigDecimalConverter)1 BigIntegerConverter (jodd.typeconverter.impl.BigIntegerConverter)1 BooleanArrayConverter (jodd.typeconverter.impl.BooleanArrayConverter)1 BooleanConverter (jodd.typeconverter.impl.BooleanConverter)1 ByteArrayConverter (jodd.typeconverter.impl.ByteArrayConverter)1 ByteConverter (jodd.typeconverter.impl.ByteConverter)1 CalendarConverter (jodd.typeconverter.impl.CalendarConverter)1 CharacterArrayConverter (jodd.typeconverter.impl.CharacterArrayConverter)1 CharacterConverter (jodd.typeconverter.impl.CharacterConverter)1 ClassArrayConverter (jodd.typeconverter.impl.ClassArrayConverter)1 ClassConverter (jodd.typeconverter.impl.ClassConverter)1