Examples of ConversionHandler


Examples of org.mvel2.ConversionHandler

class RegisterTypes implements BootstrapExecution {
  public void execute(BootstrapContext context) {
//   final ErraiServiceConfiguratorImpl config = (ErraiServiceConfiguratorImpl) context.getConfig();

    DataConversion.addConversionHandler(Queue.class, new ConversionHandler() {
      @Override
      public Object convertFrom(Object in) {
        if (in instanceof Collection) {
          return new LinkedList((Collection) in);
        }
View Full Code Here

Examples of org.mvel2.ConversionHandler

      addConversionHandler(File.class, new FileConverter());
      addConversionHandler(Dependency.class, new DependencyIdConverter());
      addConversionHandler(URL.class, new URLConverter());

      addConversionHandler(JavaResource[].class, javaResourceConversionHandler);
      addConversionHandler(JavaResource.class, new ConversionHandler()
      {

         @Override
         public Object convertFrom(final Object obj)
         {
            JavaResource[] res = (JavaResource[]) javaResourceConversionHandler.convertFrom(obj);
            if (res.length > 1)
            {
               throw new RuntimeException("ambiguous paths");
            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
                  }
               }
               return null;
            }
            else
            {
               return res[0];
            }
         }

         @Override
         @SuppressWarnings("rawtypes")
         public boolean canConvertFrom(final Class type)
         {
            return javaResourceConversionHandler.canConvertFrom(type);
         }
      });
      addConversionHandler(Resource[].class, resourceConversionHandler);
      addConversionHandler(Resource.class, new ConversionHandler()

      {
         @Override
         public Object convertFrom(final Object o)
         {
View Full Code Here

Examples of org.mvel2.ConversionHandler

      addConversionHandler(File.class, new FileConverter());
      addConversionHandler(Dependency.class, new DependencyIdConverter());
      addConversionHandler(URL.class, new URLConverter());

      addConversionHandler(JavaResource[].class, javaResourceConversionHandler);
      addConversionHandler(JavaResource.class, new ConversionHandler()
      {

         @Override
         public Object convertFrom(final Object obj)
         {
            JavaResource[] res = (JavaResource[]) javaResourceConversionHandler.convertFrom(obj);
            if (res.length > 1)
            {
               throw new RuntimeException("ambiguous paths");
            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
                  }
               }
               return null;
            }
            else
            {
               return res[0];
            }
         }

         @Override
         @SuppressWarnings("rawtypes")
         public boolean canConvertFrom(final Class type)
         {
            return javaResourceConversionHandler.canConvertFrom(type);
         }
      });
      addConversionHandler(Resource[].class, resourceConversionHandler);
      addConversionHandler(Resource.class, new ConversionHandler()

      {
         @Override
         public Object convertFrom(final Object o)
         {
View Full Code Here

Examples of org.mvel2.ConversionHandler

      addConversionHandler(File.class, new FileConverter());
      addConversionHandler(Dependency.class, new DependencyIdConverter());
      addConversionHandler(URL.class, new URLConverter());

      addConversionHandler(JavaResource[].class, javaResourceConversionHandler);
      addConversionHandler(JavaResource.class, new ConversionHandler()
      {

         @Override
         public Object convertFrom(final Object obj)
         {
            JavaResource[] res = (JavaResource[]) javaResourceConversionHandler.convertFrom(obj);
            if (res.length > 1)
            {
               throw new RuntimeException("ambiguous paths");
            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
                  }
               }
               return null;
            }
            else
            {
               return res[0];
            }
         }

         @Override
         @SuppressWarnings("rawtypes")
         public boolean canConvertFrom(final Class type)
         {
            return javaResourceConversionHandler.canConvertFrom(type);
         }
      });
      addConversionHandler(Resource[].class, resourceConversionHandler);
      addConversionHandler(Resource.class, new ConversionHandler()

      {
         @Override
         public Object convertFrom(final Object o)
         {
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

  @Test
  public void testInvalidOutwardConversion()
  {

    ConversionHandler conversionHandler = createStrictMock(ConversionHandler.class);

    IntToIntConverter converter = new IntToIntConverter();
    BindSimpleHandler handler = new BindSimpleHandler();
    TargetBean bean = new TargetBean();
    bean.setStringProperty("2");
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

    if (isDeferred()) return null;
   
    Assert.notNull(validationInfo);
    Assert.notNull(form);

    ConversionHandler conversionHandler = validationInfo.getConversionHandler();

    Map<OrderedProperty, MethodValidators> validators = validationInfo.getValidators();
    Set<OrderedProperty> keySet = validators.keySet();
    for (OrderedProperty property : keySet)
    {
      MethodValidators methodValidators = validators.get(property);
      if (methodValidators.getRequiresConversion())
      {
        if (convertedValues == null)
          convertedValues = new HashMap<String, Object>();
        Converter converter = methodValidators.getConverter();

        Object converted = null;

        // catch the conversion exception, and throw
        String propertyName = property.getPropertyName();

        try
        {
          converted = conversionHandler.getAndConvertInwards(form, propertyName, converter);

          if (converted != null)
          {

            // check that converted is actually of correct type
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

  @Test
  public void testGetConversionHandler() throws Exception
  {
    BindConvertInfo bci = createStrictMock(BindConvertInfo.class);
    ConversionHandler conversionHandler = createStrictMock(ConversionHandler.class);

    ValidationAnnotationReader reader = new ValidationAnnotationReader();

    expect(bci.getConversionHandler()).andReturn(conversionHandler);
    replay(bci);
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

      if (methodValidators != null)
        map.put(methodValidators.getOrderedProperty(), methodValidators);

    }

    ConversionHandler conversionHandler = getConversionHandler(info);

    ValidationInfo vi = new ValidationInfo(map, new DefaultValidationStrategy(), conversionHandler);
    return vi;
  }
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

  }

  ConversionHandler getConversionHandler(BindConvertInfo info)
  {
    ConversionHandler conversionHandler = null;

    if (info != null)
    {
      conversionHandler = info.getConversionHandler();
    }
View Full Code Here

Examples of org.strecks.converter.handler.ConversionHandler

    Map<String, BindHandler> bindMap = new LinkedHashMap<String, BindHandler>();
    Map<String, Converter> converterMap = new LinkedHashMap<String, Converter>();

    Class thisClass = thisBean.getClass();
    ConversionHandler conversionHandler = new DefaultConversionHandler();

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

      Annotation[] annotations = getterMethod.getAnnotations();
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.