Package java.beans

Examples of java.beans.IndexedPropertyDescriptor


        PropertyDescriptor propertyDescriptor,
        int index)
    {
        if (propertyDescriptor instanceof IndexedPropertyDescriptor) {
            try {
                IndexedPropertyDescriptor ipd =
                    (IndexedPropertyDescriptor) propertyDescriptor;
                Method method = ipd.getIndexedReadMethod();
                if (method != null) {
                    return method.invoke(
                        bean,
                        new Object[] { new Integer(index)});
                }
View Full Code Here


        int index,
        Object value)
    {
        if (propertyDescriptor instanceof IndexedPropertyDescriptor) {
            try {
                IndexedPropertyDescriptor ipd =
                    (IndexedPropertyDescriptor) propertyDescriptor;
                Method method = ipd.getIndexedWriteMethod();
                if (method != null) {
                    method.invoke(
                        bean,
                        new Object[] {
                            new Integer(index),
                            convert(value, ipd.getIndexedPropertyType())});
                    return;
                }
            }
            catch (Exception ex) {
                ex.printStackTrace();
View Full Code Here

    IndexedPropertyDescriptor oldDescriptor
    )
  {
    try
    {
      IndexedPropertyDescriptor newDescriptor = new IndexedPropertyDescriptor(
                                      oldDescriptor.getName(),
                                      oldDescriptor.getReadMethod(),
                                      oldDescriptor.getWriteMethod(),
                                      oldDescriptor.getIndexedReadMethod(),
                                      oldDescriptor.getIndexedWriteMethod());
View Full Code Here

            //

            if ((argTypes[0] == int.class) && name.startsWith(_READ_PREFIX))
            {
              // It's an indexed getter
              pd = new IndexedPropertyDescriptor(
                         decapitalize(name.substring(_READ_PREFIX.length())),
                         null,
                         null,
                         method,
                         null);
            }
            else if ((resultType == void.class) &&
                     name.startsWith(_WRITE_PREFIX))
            {
              // It's a simple setter
              pd = new PropertyDescriptor(
                             decapitalize(name.substring(_WRITE_PREFIX.length())),
                             null,
                             method);

              if (_throwsException(method, PropertyVetoException.class))
              {
                pd.setConstrained(true);
              }
            }
          }
          else if (argCount == 2)
          {
            if ((argTypes[0] == int.class) && name.startsWith(_WRITE_PREFIX))
            {
              // it's an indexed setter
              pd = new IndexedPropertyDescriptor(
                             decapitalize(name.substring(_WRITE_PREFIX.length())),
                             null,
                             null,
                             null,
                             method);

              if (_throwsException(method, PropertyVetoException.class))
              {
                pd.setConstrained(true);
              }
            }
          }
        }
        catch (IntrospectionException ex)
        {
          // This happens if a PropertyDescriptor or IndexedPropertyDescriptor
          // constructor finds that the method violates details of the design
          // pattern, e.g. by having an empty name, or a getter returning
          // void , or whatever.
          pd = null;
        }

        if (pd != null)
        {
          // If this class or one of its base classes is a PropertyChange
          // source, then we assume that any properties we discover are "bound".
          if (_propertyChangeSource)
          {
            pd.setBound(true);
          }

          // add the property to our list of properties
          _addProperty(properties, pd);
        }
      }
    }


    //
    // prune the list of properties, removing bogusly introspected properties.
    //
    Enumeration<PropertyDescriptor> elements = properties.elements();

    while (elements.hasMoreElements())
    {
      Object currElement = elements.nextElement();

      //
      // Prune out IndexedPropertyDescriptors that have no indexedGetMethods
      // and take two ints as parameters.
      //
      if (currElement instanceof IndexedPropertyDescriptor)
      {
        IndexedPropertyDescriptor indexedElement =
                                        (IndexedPropertyDescriptor)currElement;

        if (indexedElement.getIndexedReadMethod() == null)
        {
          Method writeMethod = indexedElement.getIndexedWriteMethod();

          if ((writeMethod != null) &&
              (writeMethod.getParameterTypes()[1] == int.class))
          {
            // prune this descriptor
            properties.remove(indexedElement.getName());
          }
        }
      }
    }
View Full Code Here

    Method indexedReadMethod  = null;
    Method indexedWriteMethod = null;

    if (secondaryDescriptor instanceof IndexedPropertyDescriptor)
    {
      IndexedPropertyDescriptor iSecondaryDescriptor =
                                (IndexedPropertyDescriptor)secondaryDescriptor;

      readMethod         = iSecondaryDescriptor.getReadMethod();
      writeMethod        = iSecondaryDescriptor.getWriteMethod();
      indexedReadMethod  = iSecondaryDescriptor.getIndexedReadMethod();
      indexedWriteMethod = iSecondaryDescriptor.getIndexedWriteMethod();
    }


    if (primaryDescriptor instanceof IndexedPropertyDescriptor)
    {
      IndexedPropertyDescriptor iPrimaryDescriptor =
                                (IndexedPropertyDescriptor)primaryDescriptor;

      Method tempMethod = iPrimaryDescriptor.getIndexedReadMethod();

      if (tempMethod != null)
      {
        indexedReadMethod = tempMethod;
      }

      tempMethod = iPrimaryDescriptor.getIndexedWriteMethod();

      if (tempMethod != null)
      {
        indexedWriteMethod = tempMethod;
      }
    }

    //
    // create the IndexedPropertyDescriptor with the indexed portions already
    // merged.  This is necessary because there are no setIndexedReadMethod(),
    // or setIndexedWriteMthod() until JDK 1.2
    //
    try
    {
      IndexedPropertyDescriptor mergedIndexedDescriptor =
        new IndexedPropertyDescriptor(primaryDescriptor.getName(),
                                      readMethod,
                                      writeMethod,
                                      indexedReadMethod,
                                      indexedWriteMethod);
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

                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());
                assertNull(element.getWriteMethod());
                assertNotNull(element.getReadMethod());
                assertNull(indexedDesc.getIndexedReadMethod());
                assertNotNull(indexedDesc.getIndexedWriteMethod());
                assertEquals(String.class.getName(), indexedDesc
                        .getIndexedPropertyType().getName());
            }
        }
    }
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.