Package java.beans

Examples of java.beans.IndexedPropertyDescriptor


      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 Integer(name.getIndex()), o);
View Full Code Here


    {
      return typeFromDescriptor;
    }
    if (pd instanceof IndexedPropertyDescriptor)
    {
      final IndexedPropertyDescriptor idx = (IndexedPropertyDescriptor) pd;
      return idx.getIndexedPropertyType();
    }
    throw new BeanException("Unable to determine the property type.");
  }
View Full Code Here

            PropertyDescriptor[] pds = mBeanInfo.getPropertyDescriptors();
            for (int i = 0; pds != null && i < pds.length; i++) {
                // Treat as both an indexed property and a normal property
                PropertyDescriptor pd = pds[i];
                if (pd instanceof IndexedPropertyDescriptor) {
                    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
                    Method readMethod = getPublicMethod(ipd.getIndexedReadMethod());
                    Method writeMethod = getPublicMethod(ipd.getIndexedWriteMethod());
                    BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
                            (readMethod,
                                    writeMethod,
                                    ipd);

                    mIndexedPropertyByName.put(ipd.getName(), property);
                }

                Method readMethod = getPublicMethod(pd.getReadMethod());
                Method writeMethod = getPublicMethod(pd.getWriteMethod());
                BeanInfoProperty property = new BeanInfoProperty
View Full Code Here

    public Object get(Object obj, int i)
        throws InvocationTargetException, IllegalAccessException {
        if (!isIndexed()) {
            return Array.get(get(obj), i);
        } else {
            IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)myPD;
            return id.getIndexedReadMethod().invoke(obj,
                                                    new Object[] {
                                                        new Integer(i)});
        }
    }
View Full Code Here

     */
    public void set(Object obj, int i, Object newValue)
        throws InvocationTargetException, IllegalAccessException {
        // Set the new value
        if (isIndexed()) {
            IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)myPD;
            growArrayToSize(obj, id.getIndexedPropertyType(), i);
            id.getIndexedWriteMethod().invoke(obj,
                                              new Object[] {
                                                  new Integer(i), newValue});
        } else {
            Array.set(get(obj), i, newValue);
        }
View Full Code Here

        //     JDK 1.3.1_04: returns valid Method objects from these methods.
        //     JDK 1.4.2_05: returns null from these methods.
        //
        for (int i = 0; i < descriptors.length; i++) {
            if (descriptors[i] instanceof IndexedPropertyDescriptor) {
                IndexedPropertyDescriptor descriptor =  (IndexedPropertyDescriptor)descriptors[i];
                String propName = descriptor.getName().substring(0, 1).toUpperCase() +
                                  descriptor.getName().substring(1);

                if (descriptor.getReadMethod() == null) {
                    String methodName = descriptor.getIndexedReadMethod() != null
                                        ? descriptor.getIndexedReadMethod().getName()
                                        : "get" + propName;
                    Method readMethod = MethodUtils.getMatchingAccessibleMethod(beanClass,
                                                            methodName,
                                                            EMPTY_CLASS_PARAMETERS);
                    if (readMethod != null) {
                        try {
                            descriptor.setReadMethod(readMethod);
                        } catch(Exception e) {
                            log.error("Error setting indexed property read method", e);
                        }
                    }
                }
                if (descriptor.getWriteMethod() == null) {
                    String methodName = descriptor.getIndexedWriteMethod() != null
                                      ? descriptor.getIndexedWriteMethod().getName()
                                      : "set" + propName;
                    Method writeMethod = MethodUtils.getMatchingAccessibleMethod(beanClass,
                                                            methodName,
                                                            LIST_CLASS_PARAMETER);
                    if (writeMethod == null) {
                        Method[] methods = beanClass.getMethods();
                        for (int j = 0; j < methods.length; j++) {
                            if (methods[j].getName().equals(methodName)) {
                                Class[] parameterTypes = methods[j].getParameterTypes();
                                if (parameterTypes.length == 1 &&
                                    List.class.isAssignableFrom(parameterTypes[0])) {
                                    writeMethod = methods[j];
                                    break;
                                }
                            }
                        }
                    }
                    if (writeMethod != null) {
                        try {
                            descriptor.setWriteMethod(writeMethod);
                        } catch(Exception e) {
                            log.error("Error setting indexed property write method", e);
                        }
                    }
                }
View Full Code Here

      PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
      for (int i = 0; pds != null && i < pds.length; i++) {
  // Treat as both an indexed property and a normal property
  PropertyDescriptor pd = pds [i];
  if (pd instanceof IndexedPropertyDescriptor) {
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    Method readMethod = getPublicMethod (ipd.getIndexedReadMethod ());
    Method writeMethod = getPublicMethod (ipd.getIndexedWriteMethod ());
    BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
      (readMethod,
       writeMethod,
       ipd);

    mIndexedPropertyByName.put (ipd.getName (), property);
  }

  Method readMethod = getPublicMethod (pd.getReadMethod ());
  Method writeMethod = getPublicMethod (pd.getWriteMethod ());
  BeanInfoProperty property = new BeanInfoProperty
View Full Code Here

      PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
      for (int i = 0; pds != null && i < pds.length; i++) {
  // Treat as both an indexed property and a normal property
  PropertyDescriptor pd = pds [i];
  if (pd instanceof IndexedPropertyDescriptor) {
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    Method readMethod = getPublicMethod (ipd.getIndexedReadMethod ());
    Method writeMethod = getPublicMethod (ipd.getIndexedWriteMethod ());
    BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
      (readMethod,
       writeMethod,
       ipd);

    mIndexedPropertyByName.put (ipd.getName (), property);
  }

  Method readMethod = getPublicMethod (pd.getReadMethod ());
  Method writeMethod = getPublicMethod (pd.getWriteMethod ());
  BeanInfoProperty property = new BeanInfoProperty
View Full Code Here

      PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
      for (int i = 0; pds != null && i < pds.length; i++) {
  // Treat as both an indexed property and a normal property
  PropertyDescriptor pd = pds [i];
  if (pd instanceof IndexedPropertyDescriptor) {
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    Method readMethod = getPublicMethod (ipd.getIndexedReadMethod ());
    Method writeMethod = getPublicMethod (ipd.getIndexedWriteMethod ());
    BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
      (readMethod,
       writeMethod,
       ipd);

    mIndexedPropertyByName.put (ipd.getName (), property);
  }

  Method readMethod = getPublicMethod (pd.getReadMethod ());
  Method writeMethod = getPublicMethod (pd.getWriteMethod ());
  BeanInfoProperty property = new BeanInfoProperty
View Full Code Here

      PropertyDescriptor[] pds = mBeanInfo.getPropertyDescriptors();
      for (int i = 0; pds != null && i < pds.length; i++) {
        // Treat as both an indexed property and a normal property
        PropertyDescriptor pd = pds[i];
        if (pd instanceof IndexedPropertyDescriptor) {
          IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
          Method readMethod = getPublicMethod(ipd.getIndexedReadMethod());
          Method writeMethod = getPublicMethod(ipd.getIndexedWriteMethod());
          BeanInfoIndexedProperty property = new BeanInfoIndexedProperty(readMethod, writeMethod, ipd);

          mIndexedPropertyByName.put(ipd.getName(), property);
        }

        Method readMethod = getPublicMethod(pd.getReadMethod());
        Method writeMethod = getPublicMethod(pd.getWriteMethod());
        BeanInfoProperty property = new BeanInfoProperty(readMethod, writeMethod, pd);
View Full Code Here

TOP

Related Classes of java.beans.IndexedPropertyDescriptor

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.