Package org.springframework.beans

Examples of org.springframework.beans.BeanWrapper


        /**
         * Iterate through children looking for child with id of id passed.
         */
        while(iterator.hasNext()){
            Object object = iterator.next();
            BeanWrapper wrapper = new BeanWrapperImpl(object);
            String idPropertyValue = (String) wrapper.getPropertyValue(this.idPropertyName);
            if (id.equalsIgnoreCase(idPropertyValue)) {
                child = (Serializable) object;
                break;
            }
        }
View Full Code Here


    @SuppressWarnings("unchecked")
  protected Object initChildCollection( Object parent ) throws Exception {
      if (parent == null) {
        return null;
      }
        BeanWrapper wrapper = new BeanWrapperImpl (parent);
        Object childCollection=null;
        Class propertyType = wrapper.getPropertyType( this.childCollectionProperty );
        if (List.class.isAssignableFrom( propertyType )) {
            childCollection = new ArrayList();
        } else if (Set.class.isAssignableFrom( propertyType )) {
            childCollection = new HashSet();
        } else if (Map.class.isAssignableFrom( propertyType )) {
View Full Code Here

    }
   
    /** Get the object id. */
    @SuppressWarnings("unchecked")
  private String getObjectParameterIdFromBagOrSet(Object object, Collection collection) {
        BeanWrapper wrapper = new BeanWrapperImpl(object);
        Object idValue =  wrapper.getPropertyValue(this.idPropertyName);

        if (idValue==null) {
            return "hc--" + object.hashCode();
        } else if (idValue instanceof String) {
            String strIdValue = (String) idValue;
View Full Code Here

    /** Get the object id. */
    @SuppressWarnings("unchecked")
  private String getObjectParameterIdFromList(Object object, List list) {


        BeanWrapper wrapper = new BeanWrapperImpl(object);
        Object idValue =  wrapper.getPropertyValue(this.idPropertyName);


        if (!(idValue instanceof Number || idValue == null) ) {
            throw new IllegalStateException("The value of index property is not a number");
        }
View Full Code Here

  private String getObjectParameterIdFromMap(Object object, Map map) {

        Object idValue = null;

        if (!this.idPropertyName.equals("id")) {
            BeanWrapper wrapper = new BeanWrapperImpl(object);
            idValue =  wrapper.getPropertyValue(this.idPropertyName);

            if (keyType==String.class) {
                return idValue.toString();
            } else {
                return idValue.toString();
View Full Code Here

              " specified, you must use 'parquet' with " + this.getClass().getSimpleName() + ".");
        }
      }
    }
    GenericRecordBuilder builder = new GenericRecordBuilder(schema);
    BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(entity);
    for (Schema.Field f : schema.getFields()) {
      if (beanWrapper.isReadableProperty(f.name())) {
        Schema fieldSchema = f.schema();
        if (f.schema().getType().equals(Schema.Type.UNION)) {
          for (Schema s : f.schema().getTypes()) {
            if (!s.getName().equals("null")) {
              fieldSchema = s;
            }
          }
        }
        if (fieldSchema.getType().equals(Schema.Type.RECORD)) {
          throw new StoreException("Nested record currently not supported for field: " + f.name() +
              " of type: " + beanWrapper.getPropertyDescriptor(f.name()).getPropertyType().getName());
        } else {
          if (fieldSchema.getType().equals(Schema.Type.BYTES)) {
            ByteBuffer buffer = null;
            Object value = beanWrapper.getPropertyValue(f.name());
            if (value == null || value instanceof byte[]) {
              if(value != null) {
                byte[] bytes = (byte[]) value;
                buffer = ByteBuffer.wrap(bytes);
              }
              builder.set(f.name(), buffer);
            } else {
              throw new StoreException("Don't know how to handle " + value.getClass() + " for " + fieldSchema);
            }
          } else {
            builder.set(f.name(), beanWrapper.getPropertyValue(f.name()));
            }
        }
      }
    }
    try {
View Full Code Here

                    DescribedElement element = (DescribedElement)bean;
                    setText(element.getDisplayName());
                    setToolTipText(element.getCaption());
                }
                else {
                    BeanWrapper wrapper = new BeanWrapperImpl(bean);
                    try {
                        Object text = propertyName != null ? wrapper.getPropertyValue(propertyName) : wrapper
                                .getPropertyValue("name");
                        setText(String.valueOf(text));
                    }
                    catch (FatalBeanException e) {
View Full Code Here

     * @param formModel
     * @param objectToMap
     */
    public static void mapObjectOnFormModel(FormModel formModel, Object objectToMap)
    {
        BeanWrapper beanWrapper = new BeanWrapperImpl(objectToMap);
        for (String fieldName : (Set<String>) formModel.getFieldNames())
        {
            try
            {
                formModel.getValueModel(fieldName).setValue(beanWrapper.getPropertyValue(fieldName));
            }
            catch (BeansException be)
            {
                // silently ignoring, just mapping values, so if there's one missing, don't bother
            }
View Full Code Here

    return binding;
  }

  protected void applyContext(NachoCalendarDateFieldBinding binding, Map context) {
    super.applyContext(binding, context);
        BeanWrapper wrapper = new BeanWrapperImpl(binding.getControl());
    Object dateFormat = context.get(DATE_FORMAT);
    // remove DATE_FORMAT temporarily since it is handled in the super class
    context.remove(DATE_FORMAT);
    wrapper.setPropertyValues(context);
    if (dateFormat != null) {
      // restore the original context
      context.put(DATE_FORMAT, dateFormat);
        }
  }
View Full Code Here

        Assert.isTrue((o instanceof View), "View class '" + viewClass
                + "' was instantiated, but instance is not a View!");
        View view = (View) o;
        view.setDescriptor(this);
        if (viewProperties != null) {
            BeanWrapper wrapper = new BeanWrapperImpl(view);
            wrapper.setPropertyValues(viewProperties);
        }

        if (view instanceof InitializingBean) {
            try {
                ((InitializingBean) view).afterPropertiesSet();
View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanWrapper

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.