Examples of ConverterRegistry


Examples of com.thoughtworks.xstream.converters.ConverterRegistry

        this(reflectionProvider, driver, classLoader, mapper, new ConverterLookup() {
            @Override
            public Converter lookupConverterForType(final Class<?> type) {
                return defaultConverterLookup.lookupConverterForType(type);
            }
        }, new ConverterRegistry() {
            @Override
            public void registerConverter(final Converter converter, final int priority) {
                defaultConverterLookup.registerConverter(converter, priority);
            }
        });
View Full Code Here

Examples of de.ddb.conversion.format.ConverterRegistry

    return ret;
  }

  private ConverterRegistry getConverterRegistry() {
    if (this.converterRegistry == null) {
      this.converterRegistry = new ConverterRegistry();
    }
    return this.converterRegistry;
  }
View Full Code Here

Examples of org.apache.neethi.builders.converters.ConverterRegistry

    protected AssertionBuilder<?> defaultBuilder;
    protected ConverterRegistry converters;
    protected PolicyBuilder engine;
   
    public AssertionBuilderFactoryImpl(PolicyBuilder eng) {
        this(eng, new ConverterRegistry());
    }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.util.beans.ConverterRegistry

          propertyEditor.setAsText(attributeValue);
          element.setAttribute(namespace, name, propertyEditor.getValue());
        }
        else
        {
          final ConverterRegistry instance = ConverterRegistry.getInstance();
          final ValueConverter valueConverter = instance.getValueConverter(type);
          if (valueConverter != null)
          {
            final Object o = ConverterRegistry.toPropertyValue(attributeValue, type);
            element.setAttribute(namespace, name, o);
          }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.util.beans.ConverterRegistry

    if (namespaces.length == 0)
    {
      return false;
    }

    final ConverterRegistry instance = ConverterRegistry.getInstance();
    final ElementMetaData metaData = e.getMetaData();
    boolean retval = false;

    for (int namespaceIdx = 0; namespaceIdx < namespaces.length; namespaceIdx++)
    {
      final String namespace = namespaces[namespaceIdx];
      final String[] names = e.getAttributeExpressionNames(namespace);
      for (int nameIdx = 0; nameIdx < names.length; nameIdx++)
      {
        final String name = names[nameIdx];
        final Expression ex = e.getAttributeExpression(namespace, name);
        if (ex == null)
        {
          continue;
        }

        final AttributeMetaData attribute = metaData.getAttributeDescription(namespace, name);
        if (attribute != null && attribute.isDesignTimeValue())
        {
          continue;
        }

        retval = true;
        ex.setRuntime(getRuntime());
        try
        {
          final Object value = evaluate(ex);
          if (attribute == null)
          {
            // Not a declared attribute, but maybe one of the output-handlers can work on this one.
            e.setAttribute(namespace, name, value);
          }
          else
          {
            final Class type = attribute.getTargetType();
            if (value == null || type.isAssignableFrom(value.getClass()))
            {
              e.setAttribute(namespace, name, value);
            }
            else if (value instanceof ErrorValue)
            {
              e.setAttribute(namespace, name, null);
            }
            else
            {

              final PropertyEditor propertyEditor = attribute.getEditor();
              if (propertyEditor != null)
              {
                propertyEditor.setAsText(String.valueOf(value));
                e.setAttribute(namespace, name, propertyEditor.getValue());
              }
              else
              {
                try
                {
                  final ValueConverter valueConverter = instance.getValueConverter(type);
                  if (type.isAssignableFrom(String.class))
                  {
                    // the attribute would allow raw-string values, so copy the element ..
                    e.setAttribute(namespace, name, value);
                  }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.util.beans.ConverterRegistry

    if (namespaces.length == 0)
    {
      return false;
    }

    final ConverterRegistry instance = ConverterRegistry.getInstance();
    final ElementMetaData metaData = e.getMetaData();
    boolean retval = false;

    for (int namespaceIdx = 0; namespaceIdx < namespaces.length; namespaceIdx++)
    {
      final String namespace = namespaces[namespaceIdx];
      final String[] names = e.getAttributeExpressionNames(namespace);
      for (int nameIdx = 0; nameIdx < names.length; nameIdx++)
      {
        final String name = names[nameIdx];
        final Expression ex = e.getAttributeExpression(namespace, name);
        if (ex == null)
        {
          continue;
        }

        final AttributeMetaData attribute = metaData.getAttributeDescription(namespace, name);
        if (attribute != null && attribute.isDesignTimeValue())
        {
          continue;
        }

        retval = true;
        ex.setRuntime(getRuntime());
        try
        {
          final Object value = evaluate(ex);
          if (attribute == null)
          {
            // Not a declared attribute, but maybe one of the output-handlers can work on this one.
            e.setAttribute(namespace, name, value);
          }
          else
          {
            final Class<?> type = attribute.getTargetType();
            if (value == null || type.isAssignableFrom(value.getClass()))
            {
              e.setAttribute(namespace, name, value);
            }
            else if (value instanceof ErrorValue)
            {
              if (failOnErrors)
              {
                throw new InvalidReportStateException(String.format
                    ("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
                        namespace, name,
                        FunctionUtilities.computeElementLocation(e)));
              }
              e.setAttribute(namespace, name, null);
            }
            else
            {

              final PropertyEditor propertyEditor = attribute.getEditor();
              if (propertyEditor != null)
              {
                propertyEditor.setAsText(String.valueOf(value));
                e.setAttribute(namespace, name, propertyEditor.getValue());
              }
              else
              {
                final ValueConverter valueConverter = instance.getValueConverter(type);
                if (type.isAssignableFrom(String.class))
                {
                  // the attribute would allow raw-string values, so copy the element ..
                  e.setAttribute(namespace, name, value);
                }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.util.beans.ConverterRegistry

        final PropertyEditor propertyEditor = attributeMetaData.getEditor();
        if (propertyEditor != null) {
          propertyEditor.setAsText(attributeValue);
          element.setAttribute(namespace, name, propertyEditor.getValue());
        } else {
          final ConverterRegistry instance = ConverterRegistry.getInstance();
          final ValueConverter valueConverter = instance.getValueConverter(type);
          if (valueConverter != null) {
            final Object o = ConverterRegistry.toPropertyValue(attributeValue, type);
            element.setAttribute(namespace, name, o);
          } else if (String.class.isAssignableFrom(type)) {
            // the attribute would allow raw-string values, so copy the element ..
View Full Code Here

Examples of org.springframework.core.convert.converter.ConverterRegistry

        ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
        AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
        if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
            ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
            ConversionService existingConversionService = beanFactory.getConversionService();
            ConverterRegistry converterRegistry;
            if(existingConversionService == null) {
                GenericConversionService conversionService = new GenericConversionService();
                converterRegistry = conversionService;
                beanFactory.setConversionService(conversionService);
            }
            else {
                converterRegistry = (ConverterRegistry)existingConversionService;
            }

            converterRegistry.addConverter(new Converter<GrailsApplication, org.codehaus.groovy.grails.commons.GrailsApplication>() {
                @Override
                public org.codehaus.groovy.grails.commons.GrailsApplication convert(GrailsApplication source) {
                    return new LegacyGrailsApplication(source);
                }
            });
            converterRegistry.addConverter(new Converter<ConfigMap.NullSafeNavigator, Object>() {
                @Override
                public Object convert(ConfigMap.NullSafeNavigator source) {
                    return null;
                }
            });
View Full Code Here

Examples of org.springframework.core.convert.converter.ConverterRegistry

    assertEquals(new Integer("3"), result.get(2));
  }

  @Test
  public void testSpr7766() throws Exception {
    ConverterRegistry registry = (conversionService);
    registry.addConverter(new ColorConverter());
    List<Color> colors = (List<Color>) conversionService.convert(new String[] { "ffffff", "#000000" }, TypeDescriptor.valueOf(String[].class), new TypeDescriptor(new MethodParameter(getClass().getMethod("handlerMethod", List.class), 0)));
    assertEquals(2, colors.size());
    assertEquals(Color.WHITE, colors.get(0));
    assertEquals(Color.BLACK, colors.get(1));
  }
View Full Code Here

Examples of org.springframework.core.convert.converter.ConverterRegistry

            return new TestGraphDatabaseFactory().newImpermanentDatabase();
        }

        @Override
        protected ConversionService neo4jConversionService() throws Exception {
            ConverterRegistry converterRegistry = (ConverterRegistry) super.neo4jConversionService();

            converterRegistry.addConverter(new Converter<CustomType, String>() {
                @Override
                public String convert(CustomType source) {
                    return source.value + " encoded using string";
                }
            });
            converterRegistry.addConverter(new Converter<String, CustomType>() {
                @Override
                public CustomType convert(String source) {
                    return new CustomType(source + " decoded using string");
                }
            });

            converterRegistry.addConverter(new Converter<CustomType, byte[]>() {
                @Override
                public byte[] convert(CustomType source) {
                    return (source.value + " encoded using byte array").getBytes();
                }
            });
            converterRegistry.addConverter(new Converter<byte[], CustomType>() {
                @Override
                public CustomType convert(byte[] source) {
                    return new CustomType(new String(source) + " decoded using byte array");
                }
            });
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.