Package org.springframework.beans

Examples of org.springframework.beans.BeanWrapperImpl


            return null;
        }
        else {
            String result = null;
            try {
                BeanWrapperImpl wrapper = new BeanWrapperImpl(this.getValue());
                result = wrapper.getPropertyValue(this.propertyName).toString();
            }
            catch(Exception ex) {
                throw new ReflectivePropertyEditorException("An error occurred while getting: " + this.propertyName, ex);
            }
            return result;
View Full Code Here


   * @param targetType
   *          the target type (representing a JavaBean).
   * @return an instance of the specified target type.
   */
  private Object getBeanMatchingValue(Class targetType) {
    BeanWrapper beanWrapper = new BeanWrapperImpl(targetType);
    boolean matching = true;

    int memberCount = members.size();
    for (int i = 0; i < memberCount; i++) {
      XmlRpcMember member = (XmlRpcMember) members.get(i);

      String propertyName = member.name;
      if (beanWrapper.isWritableProperty(propertyName)) {
        Class propertyType = beanWrapper.getPropertyType(propertyName);
        Object propertyValue = member.value.getMatchingValue(propertyType);

        if (propertyValue == NOT_MATCHING) {
          matching = false;
          break;
        }

        beanWrapper.setPropertyValue(propertyName, propertyValue);

      } else {
        matching = false;
        break;
      }
    }

    Object matchingValue = null;
    if (matching) {
      matchingValue = beanWrapper.getWrappedInstance();
    } else {
      matchingValue = NOT_MATCHING;
    }

    return matchingValue;
View Full Code Here

        Collection rules = parseRules(text);
        Errors errors = new BindException(target, "person");

        Object tmpTarget = null;
        if (!(target instanceof Map)) {
            tmpTarget = new BeanWrapperImpl(target);
        } else {
            tmpTarget = target;
        }
        for (Iterator iter = rules.iterator(); iter.hasNext();) {
            ValidationRule rule = (ValidationRule) iter.next();
View Full Code Here

        public boolean doCheck(Object obj) {
            PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(obj.getClass(), propertyName);
            if (propertyDescriptor == null) {
                return false;
            }
            Object value = new BeanWrapperImpl(obj).getPropertyValue(propertyName);
            return rule.isApplicable(value);
        }
View Full Code Here

     *
     * @param bean The bean to be wraped.
     * @return The bean wrapper that wraps the given bean.
     */
    protected BeanWrapper wrapBean(Object bean) {
        return new BeanWrapperImpl(bean);
    }
View Full Code Here

        assertEquals("Steven", f.getResult(new Customer("Steven")));
    }

    public void test2() {
        BeanPropertyFunction f = new BeanPropertyFunction("name");
        BeanWrapper bw = new BeanWrapperImpl(new Customer("Steven"));
        assertEquals("Steven", f.getResult(bw));
    }
View Full Code Here

            return getValue((Map) target, split(fieldName));
        }
        if (target instanceof BeanWrapper) {
            return ((BeanWrapper) target).getPropertyValue(fieldName);
        }
        return new BeanWrapperImpl(target).getPropertyValue(fieldName);
    }
View Full Code Here

   * @return the created XML-RPC struct.
   */
  private XmlRpcStruct createXmlRpcStruct(Object source) {
    XmlRpcStruct xmlRpcStruct = new XmlRpcStruct();

    BeanWrapper beanWrapper = new BeanWrapperImpl(source);
    PropertyDescriptor[] propertyDescriptors = beanWrapper
        .getPropertyDescriptors();

    int propertyDescriptorCount = propertyDescriptors.length;
    for (int i = 0; i < propertyDescriptorCount; i++) {
      PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
      String propertyName = propertyDescriptor.getName();

      if (!"class".equalsIgnoreCase(propertyName)) {
        Object propertyValue = beanWrapper.getPropertyValue(propertyName);

        XmlRpcElement xmlRpcValue = createXmlRpcElement(propertyValue);
        xmlRpcStruct.add(propertyName, xmlRpcValue);
      }
    }
View Full Code Here

            }
        }
    }

    private Class extractPropertyClass(Object target, String property) {
        BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
        return wrapper.getPropertyType(property);
    }
View Full Code Here

        return true;
    }

    public void validate(Object target, Errors errors) {

        BeanWrapper beanWrapper = (target instanceof BeanWrapper) ? (BeanWrapper) target : new BeanWrapperImpl(target);

        if (getCustomPropertyEditors() != null) {
            for (Iterator iter = getCustomPropertyEditors().iterator(); iter.hasNext();) {
                CustomPropertyEditor customPropertyEditor = (CustomPropertyEditor) iter.next();
View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanWrapperImpl

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.