Package org.strecks.converter

Examples of org.strecks.converter.Converter


  {

    InjectRequestParameter input = (InjectRequestParameter) annotation;

    Class converterClass = input.converter();
    Converter converter = RequestParameterFactory.createConverter(propertyDescriptor.getPropertyType(), converterClass);
    String parameterName = AnnotationFactoryUtils.getAttributeName(propertyDescriptor.getName(), input.name());
    boolean required = input.required();

    // make sure that converter has String generic type
    boolean ok = ReflectHelper.checkGenericType(converterClass, Converter.class, String.class);
View Full Code Here


  /**
   * Creates a converter
   */
  public static Converter createConverter(Class propertyType, Class converterClass)
  {
    Converter converter;
    try
    {
      Object newInstance = converterClass.newInstance();
      converter = (Converter) newInstance;
      converter.setTargetClass(propertyType);
    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Could not instantiate class " + converterClass.getName(), e);
    }
View Full Code Here

{

  @Test
  public void testNewMethodValidatorsNoConversion() throws Exception
  {
    Converter converter = createStrictMock(Converter.class);

    List<ValidatorWrapper> list = new ArrayList<ValidatorWrapper>();

    ValidatorWrapper v1 = getNonConvertableWrapper(String.class);
    ValidatorWrapper v2 = getNonConvertableWrapper(Object.class);
View Full Code Here

  @Test
  public void testNewMethodValidatorsWithConvesion() throws Exception
  {

    Converter converter = createStrictMock(Converter.class);

    List<ValidatorWrapper> list = new ArrayList<ValidatorWrapper>();

    ValidatorWrapper v1 = getConvertableWrapper(Integer.class);
    ValidatorWrapper v2 = getConvertableWrapper(Number.class);
    ValidatorWrapper v3 = getConvertableWrapper(Object.class);

    list.add(v1);
    list.add(v2);
    list.add(v3);

    // record expectation
    converter.setTargetClass(Integer.class);

    replay(converter);

    ValidationAnnotationReader reader = new ValidationAnnotationReader();
    MethodValidators methodValidators = reader.newMethodValidators(this.getClass(), new OrderedProperty("prop", 1),
View Full Code Here

  @Test
  public void testGetConverterNull() throws Exception
  {
    ValidationAnnotationReader reader = new ValidationAnnotationReader();
    Converter converter = reader.getConverter(this.getClass(), "prop", null);
    assert converter instanceof SafeBeanUtilsConverter;
  }
View Full Code Here

  @Test
  public void testGetConverterNone() throws Exception
  {
    BindConvertInfo info = createStrictMock(BindConvertInfo.class);
    Map converterMap = createStrictMock(Map.class);
    Converter converter = createStrictMock(Converter.class);

    ValidationAnnotationReader reader = new ValidationAnnotationReader();

    expect(info.getConverterMap()).andReturn(converterMap);
    expect(converterMap.get("prop")).andReturn(converter);
View Full Code Here

    for (Method method : thisClass.getMethods())
    {

      String setterName = method.getName();
      String propertyName = ReflectHelper.getPropertyName(setterName);
      Converter converter = getConverter(thisClass, propertyName, info);

      MethodValidators methodValidators = readMethodAnnotations(method, propertyName, converter);
      if (methodValidators != null)
        map.put(methodValidators.getOrderedProperty(), methodValidators);
View Full Code Here

    return new MethodValidators(orderedProperty, validators, converter, usesConvertedValue, converterType);
  }

  Converter getConverter(Class thisClass, String propertyName, BindConvertInfo info)
  {
    Converter converter = null;
    if (info != null)
    {
      Map<String, Converter> converterMap = info.getConverterMap();

      if (converterMap != null)
View Full Code Here

   */
  public Converter readConverter(Method method)
  {

    Annotation[] annotations = method.getAnnotations();
    Converter converter = null;

    boolean found = false;

    for (Annotation annotation : annotations)
    {
View Full Code Here

   */
  protected Converter createConverter(Class<?> propertyType, Class converterClass)
  {
    Assert.notNull(converterClass);

    Converter converter = ReflectHelper.createInstance(converterClass, Converter.class);
    converter.setTargetClass(propertyType);
    return converter;
  }
View Full Code Here

TOP

Related Classes of org.strecks.converter.Converter

Copyright © 2018 www.massapicom. 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.