Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.Converter.convert()


    if (srcFieldValue == null || destFieldClass == null || (srcFieldValue.equals("") && !destFieldClass.equals(String.class))) {
      return null;
    }
    Converter converter = getPrimitiveOrWrapperConverter(destFieldClass, dateFormatContainer);
    try {
      return converter.convert(destFieldClass, srcFieldValue);
    } catch (org.apache.commons.beanutils.ConversionException e) {
      throw new org.dozer.converters.ConversionException(e);
    }
  }
View Full Code Here


    assertNull(ConvertUtils.convert("", Long.class));
  }

  private void converToDate(String dateStr, int year, int month, int day) {
    Converter c = new SqlDateConverter();
    Date date = (Date) c.convert(Date.class, dateStr);
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    assertEquals(calendar.get(Calendar.YEAR), year);
    assertEquals(calendar.get(Calendar.MONTH), month);
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), day);
View Full Code Here

    converToDate(date1, 1980, 8, 9);
  }

  private void converToDate(String dateStr, int year, int month, int day) {
    Converter c = new DateConverter();
    Date date = (Date) c.convert(Date.class, dateStr);
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    assertEquals(calendar.get(Calendar.YEAR), year);
    assertEquals(calendar.get(Calendar.MONTH), month);
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), day);
View Full Code Here

        if (converter == null && returnType.isEnum()) {
            converter = EnumerationConverter.getInstance();
        }

        if (converter != null) {
            return converter.convert(returnType, value);
        } else {
            return converter;
        }
    }
View Full Code Here

     *
     * @param input the input string
     */
    private void checkConversionWithNullDefault(String input) {
        Converter converter = new IntegerLocaleConverter(null, Locale.US);
        assertNull("Wrong result", converter.convert(Integer.class, input));
    }

    /**
     * Tests a conversion passing in null.
     */
 
View Full Code Here

            {
                throw new UnsupportedOperationException("cant deal with " + destType);
            }

            // setting type to null, in fact the documentation is wrong here and this type is never used
            convertedValue = converter.convert(null, convertedValue);
        }
       
       
        return convertedValue;
    }
View Full Code Here

    public void testEnum() {
        Converter converter = EnumerationConverter.getInstance();

        Thread.State expected = Thread.State.TERMINATED;
        Thread.State actual = (Thread.State) converter.convert(Thread.State.class,
                Thread.State.TERMINATED.name());
        assertEquals(expected, actual);
    }

    public static Test suite() {
View Full Code Here

        Converter converter = ConvertUtils.lookup(returnType);
        if (converter == null && returnType.isEnum()) {
            converter = EnumerationConverter.getInstance();
        }
       
        return converter.convert(returnType, value);
    }

    private <A extends Annotation> Annotation createAnnotation(AnnotationType annotationType,
                                                               Class<A> returnType,
                                                               String defaultPackage) {
View Full Code Here

            }
        }

        Converter converter = ConvertUtils.lookup(useType);
        if (converter != null) {
            return converter.convert(useType, object);
        }

        throw new JXPathTypeConversionException("Cannot convert "
                + object.getClass() + " to " + useType);
    }
View Full Code Here

            {
                throw new UnsupportedOperationException("cant deal with " + destType);
            }

            // setting type to null, in fact the documentation is wrong here and this type is never used
            convertedValue = converter.convert(null, convertedValue);
        }
       
       
        return convertedValue;
    }
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.