Package org.springframework.beans

Examples of org.springframework.beans.TypeConverter


   * @param pvs the PropertyValues to register wired objects with
   */
  protected void autowireByType(
      String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {

    TypeConverter converter = getCustomTypeConverter();
    if (converter == null) {
      converter = bw;
    }

    Set<String> autowiredBeanNames = new LinkedHashSet<String>(4);
View Full Code Here


    }
    else {
      original = Arrays.asList(pvs.getPropertyValues());
    }

    TypeConverter converter = getCustomTypeConverter();
    if (converter == null) {
      converter = bw;
    }
    BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this, beanName, mbd, converter);
View Full Code Here

    if (this.targetMapClass != null) {
      keyType = GenericCollectionTypeResolver.getMapKeyType(this.targetMapClass);
      valueType = GenericCollectionTypeResolver.getMapValueType(this.targetMapClass);
    }
    if (keyType != null || valueType != null) {
      TypeConverter converter = getBeanTypeConverter();
      for (Map.Entry entry : this.sourceMap.entrySet()) {
        Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType);
        Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType);
        result.put(convertedKey, convertedValue);
      }
    }
    else {
      result.putAll(this.sourceMap);
View Full Code Here

   * @param propertyEditor editor to register
   * @see #setTypeConverter
   * @see org.springframework.beans.PropertyEditorRegistry#registerCustomEditor
   */
  public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) {
    TypeConverter converter = getTypeConverter();
    if (!(converter instanceof PropertyEditorRegistry)) {
      throw new IllegalStateException(
          "TypeConverter does not implement PropertyEditorRegistry interface: " + converter);
    }
    ((PropertyEditorRegistry) converter).registerCustomEditor(requiredType, propertyEditor);
View Full Code Here

        }
      }
    }

    // Second pass: look for method where arguments can be converted to parameter types.
    TypeConverter converter = getTypeConverter();
    if (converter != null) {
      for (int i = 0; i < candidates.length; i++) {
        if (candidates[i].getName().equals(getTargetMethod())) {
          // Check if the inspected method has the correct number of parameters.
          Class[] paramTypes = candidates[i].getParameterTypes();
          if (paramTypes.length == argCount) {
            Object[] argumentsToUse = new Object[argCount];
            int numberOfCorrectArguments = 0;
            for (int j = 0; j < argCount; j++) {
              // Verify that the supplied argument is assignable to the method parameter.
              try {
                argumentsToUse[j] = converter.convertIfNecessary(arguments[j], paramTypes[j]);
                numberOfCorrectArguments++;
              }
              catch (TypeMismatchException ex) {
                // Ignore -> simply doesn't match.
              }
View Full Code Here

    Class valueType = null;
    if (this.targetSetClass != null && JdkVersion.isAtLeastJava15()) {
      valueType = GenericCollectionTypeResolver.getCollectionType(this.targetSetClass);
    }
    if (valueType != null) {
      TypeConverter converter = getBeanTypeConverter();
      for (Iterator it = this.sourceSet.iterator(); it.hasNext();) {
        result.add(converter.convertIfNecessary(it.next(), valueType));
      }
    }
    else {
      result.addAll(this.sourceSet);
    }
View Full Code Here

    if (this.targetMapClass != null && JdkVersion.isAtLeastJava15()) {
      keyType = GenericCollectionTypeResolver.getMapKeyType(this.targetMapClass);
      valueType = GenericCollectionTypeResolver.getMapValueType(this.targetMapClass);
    }
    if (keyType != null || valueType != null) {
      TypeConverter converter = getBeanTypeConverter();
      for (Iterator it = this.sourceMap.entrySet().iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType);
        Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType);
        result.put(convertedKey, convertedValue);
      }
    }
    else {
      result.putAll(this.sourceMap);
View Full Code Here

   * @param pvs the PropertyValues to register wired objects with
   */
  protected void autowireByType(
      String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {

    TypeConverter converter = getCustomTypeConverter();
    if (converter == null) {
      converter = bw;
    }

    Set autowiredBeanNames = new LinkedHashSet(4);
View Full Code Here

    }
    else {
      original = Arrays.asList(pvs.getPropertyValues());
    }

    TypeConverter converter = getCustomTypeConverter();
    if (converter == null) {
      converter = bw;
    }
    BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this, beanName, mbd, converter);
View Full Code Here

  protected TypeConverter getCustomTypeConverter() {
    return this.typeConverter;
  }

  public TypeConverter getTypeConverter() {
    TypeConverter customConverter = getCustomTypeConverter();
    if (customConverter != null) {
      return customConverter;
    }
    else {
      // Build default TypeConverter, registering custom editors.
View Full Code Here

TOP

Related Classes of org.springframework.beans.TypeConverter

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.