Examples of convert()


Examples of jodd.typeconverter.impl.ByteConverter.convert()

  @Test
  public void testConversion() {
    ByteConverter byteConverter = new ByteConverter();

    assertNull(byteConverter.convert(null));

    assertEquals(Byte.valueOf((byte) 1), byteConverter.convert(Integer.valueOf(1)));
    assertEquals(Byte.valueOf((byte) 1), byteConverter.convert(Short.valueOf((short) 1)));
    assertEquals(Byte.valueOf((byte) 1), byteConverter.convert(Double.valueOf(1.5D)));
    assertEquals(Byte.valueOf((byte) 1), byteConverter.convert("1"));
View Full Code Here

Examples of jodd.typeconverter.impl.CalendarConverter.convert()

  @Test
  public void testCalendarDate() {
    JDateTime jdt = new JDateTime();

    CalendarConverter calendarConverter = new CalendarConverter();
    Calendar gc = calendarConverter.convert(jdt);
    DateFormat df = new SimpleDateFormat();
    assertEquals(df.format(gc.getTime()), df.format(Convert.toDate(jdt)));
  }
}
View Full Code Here

Examples of jodd.typeconverter.impl.CharacterConverter.convert()

  @Test
  public void testConversion() {
    CharacterConverter characterConverter = new CharacterConverter();

    assertNull(characterConverter.convert(null));

    assertEquals(Character.valueOf((char) 1), characterConverter.convert(Character.valueOf((char) 1)));
    assertEquals(Character.valueOf((char) 1), characterConverter.convert(Integer.valueOf(1)));
    assertEquals(Character.valueOf((char) 1), characterConverter.convert(Short.valueOf((short) 1)));
    assertEquals(Character.valueOf((char) 1), characterConverter.convert(Double.valueOf(1.0D)));
View Full Code Here

Examples of jodd.typeconverter.impl.ClassConverter.convert()

  @Test
  public void testConversion() {
    ClassConverter classConverter = new ClassConverter();

    assertNull(classConverter.convert(null));

    assertEquals(String.class, classConverter.convert(String.class));
    assertEquals(Integer.class, classConverter.convert("java.lang.Integer"));

    try {
View Full Code Here

Examples of jodd.typeconverter.impl.CollectionConverter.convert()

    if (ReflectUtil.isInterfaceImpl(destinationType, Collection.class)) {
      // component type is unknown because of Java's type-erasure
      CollectionConverter<T> collectionConverter =
          new CollectionConverter(this, destinationType, Object.class);

      return (T) collectionConverter.convert(value);
    }

    // fail
    throw new TypeConversionException("Conversion failed: " + destinationType.getName());
  }
View Full Code Here

Examples of jodd.typeconverter.impl.DoubleArrayConverter.convert()

  @Test
  public void testConversion() {
    DoubleArrayConverter doubleArrayConverter = (DoubleArrayConverter) TypeConverterManager.lookup(double[].class);

    assertNull(doubleArrayConverter.convert(null));

    assertEq(arrd(1.73), doubleArrayConverter.convert(Double.valueOf(1.73)));
    assertEq(arrd(1.73, 10.22), doubleArrayConverter.convert(arrd(1.73, 10.22)));
    assertEq(arrd(1.0, 7.0, 3.0), doubleArrayConverter.convert(arri(1, 7, 3)));
    assertEq(arrd(1.0, 7.0, 3.0), doubleArrayConverter.convert(arrl(1, 7, 3)));
View Full Code Here

Examples of jodd.typeconverter.impl.DoubleConverter.convert()

  @Test
  public void testConversion() {
    DoubleConverter doubleConverter = new DoubleConverter();

    assertNull(doubleConverter.convert(null));

    assertEquals(Double.valueOf(1), doubleConverter.convert(Integer.valueOf(1)));
    assertEquals(Double.valueOf(1.73), doubleConverter.convert(Double.valueOf(1.73D)));
    assertEquals(Double.valueOf(1.73), doubleConverter.convert("1.73"));
    assertEquals(Double.valueOf(1.73), doubleConverter.convert(" 1.73 "));
View Full Code Here

Examples of jodd.typeconverter.impl.FloatArrayConverter.convert()

  @Test
  public void testConversion() {
    FloatArrayConverter floatArrayConverter = (FloatArrayConverter) TypeConverterManager.lookup(float[].class);

    assertNull(floatArrayConverter.convert(null));

    assertEq(arrf((float) 1.73), floatArrayConverter.convert(Float.valueOf((float) 1.73)));
    assertEq(arrf((float) 1.73, (float) 10.22), floatArrayConverter.convert(arrf((float) 1.73, (float) 10.22)));
    assertEq(arrf((float) 1.73, (float) 10.22), floatArrayConverter.convert(arrd(1.73, 10.22)));
    assertEq(arrf((float) 1.73, (float) 10.22), floatArrayConverter.convert(arrf(1.73f, 10.22f)));
View Full Code Here

Examples of jodd.typeconverter.impl.FloatConverter.convert()

  @Test
  public void testConversion() {
    FloatConverter floatConverter = new FloatConverter();

    assertNull(floatConverter.convert(null));

    assertEquals(Float.valueOf(1), floatConverter.convert(Integer.valueOf(1)));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(Double.valueOf(1.73D)));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert("1.73"));
    assertEquals(Float.valueOf((float) 1.73), floatConverter.convert(" 1.73 "));
View Full Code Here

Examples of jodd.typeconverter.impl.IntegerArrayConverter.convert()

  @Test
  public void testConversion() {
    IntegerArrayConverter integerArrayConverter = (IntegerArrayConverter) TypeConverterManager.lookup(int[].class);

    assertNull(integerArrayConverter.convert(null));

    assertEq(arri(173, 234), integerArrayConverter.convert("173, 234"));
    assertEq(arri(173), integerArrayConverter.convert(Double.valueOf(173)));
    assertEq(arri(1, 7, 3), integerArrayConverter.convert(arri(1, 7, 3)));
    assertEq(arri(1, 7, 3), integerArrayConverter.convert(arrl(1, 7, 3)));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.