Package org.springframework.beans

Examples of org.springframework.beans.SimpleTypeConverter


  /**
   * Return this binder's underlying SimpleTypeConverter.
   */
  protected SimpleTypeConverter getSimpleTypeConverter() {
    if (this.typeConverter == null) {
      this.typeConverter = new SimpleTypeConverter();
    }
    return this.typeConverter;
  }
View Full Code Here


    BeanFactory beanFactory = getBeanFactory();
    if (beanFactory instanceof ConfigurableBeanFactory) {
      return ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
    }
    else {
      return new SimpleTypeConverter();
    }
  }
View Full Code Here

    if (customConverter != null) {
      return customConverter;
    }
    else {
      // Build default TypeConverter, registering custom editors.
      SimpleTypeConverter typeConverter = new SimpleTypeConverter();
      registerCustomEditors(typeConverter);
      return typeConverter;
    }
  }
View Full Code Here

    protected final Map<String, String> parameterKeys = createLinkedHashMap();
    protected final ParserRequestContext requestContext;

    public AbstractValueParser(ParserRequestContext requestContext) {
        this.requestContext = requestContext;
        this.converter = new SimpleTypeConverter();
        this.converter.registerCustomEditor(String.class, new StringFileItemEditor());

        if (requestContext.getPropertyEditorRegistrar() != null) {
            requestContext.getPropertyEditorRegistrar().registerCustomEditors(converter);
        }
View Full Code Here

            inf.end();
        }
    }

    protected final TypeConverter getTypeConverter() {
        SimpleTypeConverter typeConverter = new SimpleTypeConverter();
        propertyEditorRegistrars.registerCustomEditors(typeConverter);
        return typeConverter;
    }
View Full Code Here

public class ValueListSupportTests {
    private ValueListSupport values;

    @Before
    public void init() {
        values = new ValueListSupport(new SimpleTypeConverter(), true);
    }
View Full Code Here

                    namespaceHandler.parse(element, parserContext);
                    return new RuntimeBeanReference(id);
                }

                // Just use the text in the element as the value.
        SimpleTypeConverter converter = new SimpleTypeConverter();
        return converter.convertIfNecessary(element.getTextContent(), clazz);
      }
    }
  }
View Full Code Here

        this.methodInfo = methodInfo;
        this.parameterValues = parameterValues;
    }

    public Object invoke(BeanFactory beanFactory, Object rootBuilder, Object contextBuilder) {
        SimpleTypeConverter converter = new SimpleTypeConverter();
        Object args[] = new Object[methodInfo.parameters.size()];
        int pos = 0;
        for (Map.Entry<String, Class> entry : methodInfo.parameters.entrySet()) {
            String paramName = entry.getKey();
            Class paramClass = entry.getValue();
            Object value = parameterValues.get(paramName);
            if (value != null) {
                value = replaceBeanReferences(beanFactory, rootBuilder, value);
                args[pos] = converter.convertIfNecessary(value, paramClass);
            }
        }

        try {
            return methodInfo.method.invoke(contextBuilder, args);
View Full Code Here

    BeanFactory beanFactory = getBeanFactory();
    if (beanFactory instanceof ConfigurableBeanFactory) {
      return ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
    }
    else {
      return new SimpleTypeConverter();
    }
  }
View Full Code Here

    if (descriptor == null || ObjectUtils.isEmpty(descriptor.getAnnotations())) {
      // no qualification necessary
      return true;
    }
    AbstractBeanDefinition bd = (AbstractBeanDefinition) bdHolder.getBeanDefinition();
    SimpleTypeConverter typeConverter = new SimpleTypeConverter();
    Annotation[] annotations = (Annotation[]) descriptor.getAnnotations();
    for (Annotation annotation : annotations) {
      Class<? extends Annotation> type = annotation.annotationType();
      if (isQualifier(type)) {
        AutowireCandidateQualifier qualifier = bd.getQualifier(type.getName());
        if (qualifier == null) {
          qualifier = bd.getQualifier(ClassUtils.getShortName(type));
        }
        if (qualifier == null && bd.hasBeanClass()) {
          // look for matching annotation on the target class
          Class<?> beanClass = bd.getBeanClass();
          Annotation targetAnnotation = beanClass.getAnnotation(type);
          if (targetAnnotation != null && targetAnnotation.equals(annotation)) {
            return true;
          }
        }
        Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
        if (attributes.isEmpty() && qualifier == null) {
          // if no attributes, the qualifier must be present
          return false;
        }
        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
          String attributeName = entry.getKey();
          Object expectedValue = entry.getValue();
          Object actualValue = null;
          // check qualifier first
          if (qualifier != null) {
            actualValue = qualifier.getAttribute(attributeName);
          }
          if (actualValue == null) {
            // fall back on bean definition attribute
            actualValue = bd.getAttribute(attributeName);
          }
          if (actualValue == null && attributeName.equals(AutowireCandidateQualifier.VALUE_KEY) &&
              (expectedValue.equals(bdHolder.getBeanName()) ||
                  ObjectUtils.containsElement(bdHolder.getAliases(), expectedValue))) {
            // fall back on bean name (or alias) match
            continue;
          }
          if (actualValue == null && qualifier != null) {
            // fall back on default, but only if the qualifier is present
            actualValue = AnnotationUtils.getDefaultValue(annotation, attributeName);
          }
          if (actualValue != null) {
            actualValue = typeConverter.convertIfNecessary(actualValue, expectedValue.getClass());
          }
          if (!expectedValue.equals(actualValue)) {
            return false;
          }
        }
View Full Code Here

TOP

Related Classes of org.springframework.beans.SimpleTypeConverter

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.