Examples of canConvert()


Examples of org.apache.hivemind.service.ClassFab.canConvert()

    public void testCanConvert()
    {
      final ClassFab cf = newClassFab("BamBam", Object.class);
      assertTrue( cf.canConvert( String.class ) );
      assertFalse(cf.canConvert(CglibBeanInterfaceFactory.createCglibBean().getClass()));
      assertFalse(cf.canConvert(JavassistBeanInterfaceFactory.createJavassistBean().getClass()));
      assertFalse(cf.canConvert(JdkBeanInterfaceFactory.createJdkBean().getClass()));
    }
   
    /** @since 1.1 */
 
View Full Code Here

Examples of org.apache.hivemind.service.ClassFab.canConvert()

    public void testCanConvert()
    {
      final ClassFab cf = newClassFab("BamBam", Object.class);
      assertTrue( cf.canConvert( String.class ) );
      assertFalse(cf.canConvert(CglibBeanInterfaceFactory.createCglibBean().getClass()));
      assertFalse(cf.canConvert(JavassistBeanInterfaceFactory.createJavassistBean().getClass()));
      assertFalse(cf.canConvert(JdkBeanInterfaceFactory.createJdkBean().getClass()));
    }
   
    /** @since 1.1 */
    private void contains(String actual, String expected)
View Full Code Here

Examples of org.apache.hivemind.service.ClassFab.canConvert()

    {
      final ClassFab cf = newClassFab("BamBam", Object.class);
      assertTrue( cf.canConvert( String.class ) );
      assertFalse(cf.canConvert(CglibBeanInterfaceFactory.createCglibBean().getClass()));
      assertFalse(cf.canConvert(JavassistBeanInterfaceFactory.createJavassistBean().getClass()));
      assertFalse(cf.canConvert(JdkBeanInterfaceFactory.createJdkBean().getClass()));
    }
   
    /** @since 1.1 */
    private void contains(String actual, String expected)
    {
View Full Code Here

Examples of org.codehaus.plexus.component.configurator.converters.ConfigurationConverter.canConvert()

    {
        for ( Iterator iterator = converters.iterator(); iterator.hasNext(); )
        {
            ConfigurationConverter converter = (ConfigurationConverter) iterator.next();

            if ( converter.canConvert( type ) )
            {
                converterMap.put( type, converter );

                return converter;
            }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

    DataBinder binder = binderFactory.createBinder(request, null, attributeName);
    ConversionService conversionService = binder.getConversionService();
    if (conversionService != null) {
      TypeDescriptor source = TypeDescriptor.valueOf(String.class);
      TypeDescriptor target = new TypeDescriptor(parameter);
      if (conversionService.canConvert(source, target)) {
        return binder.convertIfNecessary(sourceValue, parameter.getParameterType(), parameter);
      }
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

    // No custom editor but custom ConversionService specified?
    ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
    if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
      TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
      TypeDescriptor targetTypeDesc = typeDescriptor;
      if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
        try {
          return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
        }
        catch (ConversionFailedException ex) {
          // fallback to default conversion logic below
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

    DataBinder binder = binderFactory.createBinder(request, null, attributeName);
    ConversionService conversionService = binder.getConversionService();
    if (conversionService != null) {
      TypeDescriptor source = TypeDescriptor.valueOf(String.class);
      TypeDescriptor target = new TypeDescriptor(parameter);
      if (conversionService.canConvert(source, target)) {
        return binder.convertIfNecessary(sourceValue, parameter.getParameterType(), parameter);
      }
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

    // No custom editor but custom ConversionService specified?
    ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
    if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
      TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
      TypeDescriptor targetTypeDesc = typeDescriptor;
      if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
        try {
          return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
        }
        catch (ConversionFailedException ex) {
          // fallback to default conversion logic below
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

    // No custom editor but custom ConversionService specified?
    ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
    if (editor == null && conversionService != null && convertedValue != null) {
      TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(convertedValue);
      if (conversionService.canConvert(sourceTypeDesc, typeDescriptor)) {
        return (T) conversionService.convert(convertedValue, sourceTypeDesc, typeDescriptor);
      }
    }

    // Value not of required type?
View Full Code Here

Examples of org.springframework.core.convert.ConversionService.canConvert()

            // A List of size 1 get's returned as the object at list[0].
            Object obj = results.get(0);
            if (obj.getClass() != targetType) {
              // I can't just return it as-is, I have to convert it first.
              ConversionService conv = getConversionService();
              if (conv.canConvert(obj.getClass(), targetType)) {
                return conv.convert(obj, targetType);
              } else {
                throw new DataAccessResourceFailureException(
                    "Can't find a converter to to convert " + obj
                        .getClass() + " returned from M/R job to required type " + targetType);
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.