ariba.util.expr
Class ObjectIndexedPropertyDescriptor

java.lang.Object
  extended by java.beans.FeatureDescriptor
      extended by java.beans.PropertyDescriptor
          extended by ariba.util.expr.ObjectIndexedPropertyDescriptor

public class ObjectIndexedPropertyDescriptor
extends java.beans.PropertyDescriptor

PropertyDescriptor subclass that describes an indexed set of read/write methods to get a property. Unlike IndexedPropertyDescriptor this allows the "key" to be an arbitrary object rather than just an int. Consequently it does not have a "readMethod" or "writeMethod" because it only expects a pattern like:

    public void setProperty(KeyType, ValueType);
    public ValueType getProperty(KeyType);

and does not require the methods that access it as an array. AribaExpr can get away with this without losing functionality because if the object does expose the properties they are most probably in a Map and that case is handled by the normal AribaExpr property accessors.

For example, if an object were to have methods that accessed and "attributes" property it would be natural to index them by String rather than by integer and expose the attributes as a map with a different property name:

    public void setAttribute(String name, Object value);
    public Object getAttribute(String name);
    public Map getAttributes();

Note that the index get/set is called get/set Attribute whereas the collection getter is called Attributes. This case is handled unambiguously by the AribaExpr property accessors because the set/getAttribute methods are detected by this object and the "attributes" case is handled by the MapPropertyAccessor. Therefore AribaExpr expressions calling this code would be handled in the following way:

AribaExpr Expression Handling
attribute["name"] Handled by an index getter, like getAttribute(String).
attribute["name"] = value Handled by an index setter, like setAttribute(String, Object).
attributes["name"] Handled by MapPropertyAccessor via a Map.get(). This will not go through the index get accessor.
attributes["name"] = value Handled by MapPropertyAccessor via a Map.put(). This will not go through the index set accessor.

Author:
Luke Blanshard (blanshlu@netscape.net), Drew Davidson (drew@ognl.org)

Constructor Summary
ObjectIndexedPropertyDescriptor(java.lang.String propertyName, java.lang.Class propertyType, java.lang.reflect.Method indexedReadMethod, java.lang.reflect.Method indexedWriteMethod)
           
 
Method Summary
 java.lang.reflect.Method getIndexedReadMethod()
           
 java.lang.reflect.Method getIndexedWriteMethod()
           
 java.lang.Class getPropertyType()
           
 
Methods inherited from class java.beans.PropertyDescriptor
createPropertyEditor, equals, getPropertyEditorClass, getReadMethod, getWriteMethod, hashCode, isBound, isConstrained, setBound, setConstrained, setPropertyEditorClass, setReadMethod, setWriteMethod
 
Methods inherited from class java.beans.FeatureDescriptor
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectIndexedPropertyDescriptor

public ObjectIndexedPropertyDescriptor(java.lang.String propertyName,
                                       java.lang.Class propertyType,
                                       java.lang.reflect.Method indexedReadMethod,
                                       java.lang.reflect.Method indexedWriteMethod)
                                throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException
Method Detail

getIndexedReadMethod

public java.lang.reflect.Method getIndexedReadMethod()

getIndexedWriteMethod

public java.lang.reflect.Method getIndexedWriteMethod()

getPropertyType

public java.lang.Class getPropertyType()
Overrides:
getPropertyType in class java.beans.PropertyDescriptor


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.