Package java.beans

Examples of java.beans.PropertyDescriptor


      if (collection != null) {
        OneToMany oneToMany = collection.getAnnotation(OneToMany.class);
      if (oneToMany != null) {
        String reverse = oneToMany.mappedBy();
        if (hasText(reverse)) {
          PropertyDescriptor reverseProperty = BeanUtils.getPropertyDescriptor(target, reverse);
          if (reverseProperty != null) reverseSetter = reverseProperty.getWriteMethod();
        }
      }
      if (reverseSetter == null) {
        Class<?> targetFieldClass = ClassUtils.getGenericType(collection);
        if (targetFieldClass != null)
          for (PropertyDescriptor reverseProperty : BeanUtils.getPropertyDescriptors(targetFieldClass))
            if (reverseProperty.getPropertyType().isAssignableFrom(primary))
              reverseSetter = reverseProperty.getWriteMethod();
      }
      }
    return reverseSetter;
    }
View Full Code Here


        for (PropertyDescriptor targetPd : targetPds) {
            String name = targetPd.getName();
            Method writeMethod = targetPd.getWriteMethod();
            if ((ignoreProperties == null) || (!ignoreProperties.contains(name))) {
                if (Hibernate.isPropertyInitialized(source, name) & (writeMethod != null)) {
                    PropertyDescriptor sourcePd = org.springframework.beans.BeanUtils.getPropertyDescriptor(clazz, name);
                    try {
                        Method readMethod = sourcePd.getReadMethod();
                        Object value = readMethod.invoke(source);
                        if (Hibernate.isInitialized(value)) writeMethod.invoke(target, new Object[]{value});
                    } catch (Exception ex) {
                        throw new FatalBeanException("Could not copy property[" + name + "] from source to target", ex);
                    }
View Full Code Here

  }

  private Object getPropertyForSpecification(final PropertySpecification name)
      throws BeanException
  {
    final PropertyDescriptor pd = (PropertyDescriptor) properties.get(name.getName());
    if (pd == null)
    {
      throw new BeanException("No such property:" + name);
    }

    if (pd instanceof IndexedPropertyDescriptor && name.getIndex() != null)
    {
      final IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
      final Method readMethod = ipd.getIndexedReadMethod();
      if (readMethod == null)
      {
        throw new BeanException("Property is not readable: " + name);
      }
      try
      {
        return readMethod.invoke(bean, new Object[]{new Integer(name.getIndex())});
      }
      catch (Exception e)
      {
        throw BeanException.getInstance("InvokationError", e);
      }
    }
    else
    {
      final Method readMethod = pd.getReadMethod();
      if (readMethod == null)
      {
        throw BeanException.getInstance("Property is not readable: " + name, null);
      }
      if (name.getIndex() != null)
View Full Code Here

  public String getPropertyAsString(final String name)
      throws BeanException
  {
    final PropertySpecification ps = new PropertySpecification(name);
    final PropertyDescriptor pd = (PropertyDescriptor) properties.get(ps.getName());
    if (pd == null)
    {
      throw new BeanException("No such property:" + name);
    }
    final Object o = getPropertyForSpecification(ps);
View Full Code Here

  }

  private void setProperty(final PropertySpecification name, final Object o)
      throws BeanException
  {
    final PropertyDescriptor pd = (PropertyDescriptor) properties.get(name.getName());
    if (pd == null)
    {
      throw new BeanException("No such property:" + name);
    }

    if (pd instanceof IndexedPropertyDescriptor && name.getIndex() != null)
    {
      final IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
      final Method writeMethod = ipd.getIndexedWriteMethod();
      if (writeMethod != null)
      {
        try
        {
          writeMethod.invoke(bean, new Object[]{new Integer(name.getIndex()), o});
        }
        catch (Exception e)
        {
          throw BeanException.getInstance("InvokationError", e);
        }
        // we've done the job ...
        return;
      }
    }

    final Method writeMethod = pd.getWriteMethod();
    if (writeMethod == null)
    {
      throw BeanException.getInstance("Property is not writeable: " + name, null);
    }
View Full Code Here

    if (txt == null)
    {
      throw new NullPointerException("Text must not be null");
    }
    final PropertySpecification ps = new PropertySpecification(name);
    final PropertyDescriptor pd = (PropertyDescriptor) properties.get(ps.getName());
    if (pd == null)
    {
      throw new BeanException("No such property:" + name);
    }
View Full Code Here

    if (name == null)
    {
      throw new NullPointerException("Name must not be null");
    }
    final PropertySpecification ps = new PropertySpecification(name);
    final PropertyDescriptor pd = (PropertyDescriptor) properties.get(ps.getName());
    if (pd == null)
    {
      throw new BeanException("No such property:" + name);
    }
    return BeanUtility.getPropertyType(pd);
View Full Code Here

  {
    final ArrayList propertyNames = new ArrayList();
    final PropertyDescriptor[] pd = getPropertyInfos();
    for (int i = 0; i < pd.length; i++)
    {
      final PropertyDescriptor property = pd[i];
      if (property.isHidden())
      {
        continue;
      }
      if (property.getReadMethod() == null ||
          property.getWriteMethod() == null)
      {
        // it will make no sense to write a property now, that
        // we can't read in later...
        continue;
      }
      if (BeanUtility.getPropertyType(property).isArray())
      {
        final int max = findMaximumIndex(property);
        for (int idx = 0; idx < max; idx++)
        {
          propertyNames.add(property.getName() + '[' + idx + ']');
        }
      }
      else
      {
        propertyNames.add(property.getName());
      }
    }
    return (String[]) propertyNames.toArray(new String[propertyNames.size()]);
  }
View Full Code Here

    propertyEditorClass = attrs.getValue(getUri(), "propertyEditor");

    final PropertyDescriptor[] descriptors = expression.getPropertyDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      final PropertyDescriptor maybeDescriptor = descriptors[i];
      if (name.equals(maybeDescriptor.getName()))
      {
        descriptor = maybeDescriptor;
        break;
      }
    }
View Full Code Here

    propertyEditorClass = attrs.getValue(getUri(), "propertyEditor"); // NON-NLS
    final PropertyDescriptor[] descriptors = expression.getPropertyDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      final PropertyDescriptor maybeDescriptor = descriptors[i];
      if (name.equals(maybeDescriptor.getName()))
      {
        descriptor = maybeDescriptor;
        break;
      }
    }
View Full Code Here

TOP

Related Classes of java.beans.PropertyDescriptor

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.