Package java.beans

Examples of java.beans.IndexedPropertyDescriptor


                break;
            }
        }
        assertNotNull(pd);
        assertTrue(pd instanceof IndexedPropertyDescriptor);
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        assertNull(ipd.getReadMethod());
        assertNull(ipd.getWriteMethod());
        Method indexedReadMethod = beanClass.getMethod("getData",
                new Class[] { int.class });
        Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
                int.class, int.class });
        assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
        assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
    }
View Full Code Here


                break;
            }
        }
        assertNotNull(pd);
        assertTrue(pd instanceof IndexedPropertyDescriptor);
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        assertNull(ipd.getReadMethod());
        assertNull(ipd.getWriteMethod());
        Method indexedReadMethod = beanClass.getMethod("getData",
                new Class[] { int.class });
        Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
                int.class, int.class });
        assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
        assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
    }
View Full Code Here

        for (PropertyDescriptor element : pds) {
            if (element.getName().equals("class")) {
                assertNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
            } else {
                IndexedPropertyDescriptor indexedDesc =
                        (IndexedPropertyDescriptor) element;
               
                assertEquals("fox401", element.getName());
                assertEquals(String[].class.getName(), element
                        .getPropertyType().getName());
                assertEquals(String.class.getName(), indexedDesc
                        .getIndexedPropertyType().getName());
                assertNotNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
                assertNotNull(indexedDesc.getIndexedReadMethod());
                assertNotNull(indexedDesc.getIndexedWriteMethod());
            }
        }
    }
View Full Code Here

        for (PropertyDescriptor element : propertyDesc) {
            if (element.getName().equals("class")) {
                assertNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
            } else {
                IndexedPropertyDescriptor indexedDesc =
                        (IndexedPropertyDescriptor) element;
               
                assertEquals("fox501", element.getName());
                assertEquals(String[].class.getName(), element
                        .getPropertyType().getName());
                assertNotNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
                assertNotNull(indexedDesc.getIndexedReadMethod());
                assertNull(indexedDesc.getIndexedWriteMethod());
                assertEquals(String.class.getName(), indexedDesc
                        .getIndexedPropertyType().getName());
            }
        }
    }
View Full Code Here

        for (PropertyDescriptor element : propertyDesc) {
            if (element.getName().equals("class")) {
                assertNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
            } else {
                IndexedPropertyDescriptor indexedDesc = (IndexedPropertyDescriptor) element;
                assertEquals("fox501", element.getName());
                assertNull(element.getPropertyType());
                assertNull(element.getWriteMethod());
                assertNull(element.getReadMethod());
                assertNull(indexedDesc.getIndexedReadMethod());
                assertNotNull(indexedDesc.getIndexedWriteMethod());
                assertEquals(Integer.class.getName(), indexedDesc
                        .getIndexedPropertyType().getName());
            }
        }
    }
View Full Code Here

    if (this == obj) {
      return true;
    }

    if (obj != null && obj instanceof IndexedPropertyDescriptor) {
      IndexedPropertyDescriptor other = (IndexedPropertyDescriptor) obj;
      if (!compareMethods(getIndexedReadMethod(), other.getIndexedReadMethod())) {
        return false;
      }

      if (!compareMethods(getIndexedWriteMethod(), other.getIndexedWriteMethod())) {
        return false;
      }

      if (getIndexedPropertyType() != other.getIndexedPropertyType()) {
        return false;
      }
      return PropertyDescriptorUtils.equals(this, obj);
    }
    return false;
View Full Code Here

    for (PropertyDescriptor pd : this.propertyDescriptors) {
      final Class<?> candidateType;
      final String candidateName = pd.getName();
      if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        candidateType = ipd.getIndexedPropertyType();
        if (candidateName.equals(propertyName) &&
            (candidateType.equals(propertyType) ||
                candidateType.equals(propertyType.getComponentType()))) {
          return pd;
        }
View Full Code Here

        DELEGATE_PD:
        for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
          if (!(pd instanceof IndexedPropertyDescriptor)) {
            continue DELEGATE_PD;
          }
          IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
          Method readMethod = ipd.getReadMethod();
          Method writeMethod = ipd.getWriteMethod();
          Method indexedReadMethod = ipd.getIndexedReadMethod();
          Method indexedWriteMethod = ipd.getIndexedWriteMethod();
          // has the setter already been found by the wrapped BeanInfo?
          if (indexedWriteMethod != null
              && indexedWriteMethod.getName().equals(method.getName())) {
            // yes -> copy it, including corresponding getter method (if any -- may be null)
            this.addOrUpdatePropertyDescriptor(pd, propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
View Full Code Here

          existingPD.setWriteMethod(writeMethod);
        }

        // is this descriptor indexed?
        if (existingPD instanceof IndexedPropertyDescriptor) {
          IndexedPropertyDescriptor existingIPD = (IndexedPropertyDescriptor) existingPD;

          // is there already a descriptor that captures this indexed read method or its corresponding indexed write method?
          if (existingIPD.getIndexedReadMethod() != null) {
            if (indexedReadMethod != null && existingIPD.getIndexedReadMethod().getReturnType() != indexedReadMethod.getReturnType()
                || indexedWriteMethod != null && existingIPD.getIndexedReadMethod().getReturnType() != indexedWriteMethod.getParameterTypes()[1]) {
              // no -> add a new descriptor for it below
              break;
            }
          }
          // update the existing descriptor's indexed read method
          try {
            if (indexedReadMethod != null) {
              existingIPD.setIndexedReadMethod(indexedReadMethod);
            }
          } catch (IntrospectionException ex) {
            // there is a conflicting indexed setter method present -> null it out and try again
            existingIPD.setIndexedWriteMethod(null);
            existingIPD.setIndexedReadMethod(indexedReadMethod);
          }

          // is there already a descriptor that captures this indexed write method or its corresponding indexed read method?
          if (existingIPD.getIndexedWriteMethod() != null) {
            if (indexedReadMethod != null && existingIPD.getIndexedWriteMethod().getParameterTypes()[1] != indexedReadMethod.getReturnType()
                || indexedWriteMethod != null && existingIPD.getIndexedWriteMethod().getParameterTypes()[1] != indexedWriteMethod.getParameterTypes()[1]) {
              // no -> add a new descriptor for it below
              break;
            }
          }
          // update the existing descriptor's indexed write method
          if (indexedWriteMethod != null) {
            existingIPD.setIndexedWriteMethod(indexedWriteMethod);
          }
        }

        // the descriptor has been updated -> return immediately
        return;
      }
    }

    // we haven't yet seen read or write methods for this property -> add a new descriptor
    if (pd == null) {
      try {
        if (indexedReadMethod == null && indexedWriteMethod == null) {
          pd = new PropertyDescriptor(propertyName, readMethod, writeMethod);
        }
        else {
          pd = new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
        }
        this.propertyDescriptors.add(pd);
      } catch (IntrospectionException ex) {
        logger.warn(format("Could not create new PropertyDescriptor for readMethod [%s] writeMethod [%s] " +
            "indexedReadMethod [%s] indexedWriteMethod [%s] for property [%s]. Reason: %s",
View Full Code Here

            vector.add(new PropertyDescriptor("preferredSize", AttributeNumberScalarIcon.class
                    .getSuperclass()));
            vector.add(new PropertyDescriptor("simuled", AttributeNumberScalarIcon.class));
            vector.add(new PropertyDescriptor("symbolWidth", AttributeNumberScalarIcon.class));
            vector.add(new PropertyDescriptor("symbolHeight", AttributeNumberScalarIcon.class));
            vector.add(new IndexedPropertyDescriptor("iconNameList",
                    AttributeNumberScalarIcon.class));
            vector.add(new PropertyDescriptor("helpText", AttributeNumberScalarIcon.class));
            vector.add(new PropertyDescriptor("defaultHelpText", AttributeNumberScalarIcon.class));
            vector.add(new PropertyDescriptor("background", AttributeNumberScalarIcon.class
                    .getSuperclass()));
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.