Package java.beans

Examples of java.beans.IndexedPropertyDescriptor


                PropertySoleilTracerDotStyleEditor.class);
        PropertyEditorManager.registerEditor(double.class, PropertyNegativeDoubleEditor.class);

        try {
            final Vector<PropertyDescriptor> vector = new Vector<PropertyDescriptor>();
            vector.add(new IndexedPropertyDescriptor("attributeNameList", AttributeTracer.class));
            vector.add(new PropertyDescriptor("refreshingPeriod", AttributeTracer.class));
            vector.add(new PropertyDescriptor("simuled", AttributeTracer.class));
            vector.add(new PropertyDescriptor("drawStyle", AttributeTracer.class));
            vector.add(new PropertyDescriptor("dotStyle", AttributeTracer.class));
            vector.add(new PropertyDescriptor("defaultMinValue", AttributeTracer.class));
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

            //

            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

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

    if (!(pd instanceof IndexedPropertyDescriptor)) {
    throw new IllegalArgumentException ("attempt to get non-indexed " +
                      "property '" + propName +
                      "' as being indexed");
    }
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    rm = ipd.getIndexedReadMethod ();
    propType = ipd.getIndexedPropertyType ();
  } else {
    rm = pd.getReadMethod ();
    propType = pd.getPropertyType ();
  }
View Full Code Here

    if (!(pd instanceof IndexedPropertyDescriptor)) {
    throw new IllegalArgumentException ("attempt to set non-indexed " +
                      "property '" + propName +
                      "' as being indexed");
    }
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    wm = ipd.getIndexedWriteMethod ();
    propType = ipd.getIndexedPropertyType ();
  } else {
    wm = pd.getWriteMethod ();
    propType = pd.getPropertyType ();
  }
View Full Code Here

            fail("Expected RuntimeException: tried to use a property with no read method");
        } catch (RuntimeException expected) {}
    }
   
    public void testFillStatementWithBeanErrorBadReadMethod() throws Exception {
        PropertyDescriptor badReadMethod = new IndexedPropertyDescriptor("indexed", getClass(), null, null, "getIndexed", null) {
            public synchronized Method getReadMethod() {
                return super.getIndexedReadMethod();
            }
        };
        PropertyDescriptor properties[] = new PropertyDescriptor[] { badReadMethod };
View Full Code Here

      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
View Full Code Here

      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});
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.