atg.beans
Class DynamicPropertyDescriptor

java.lang.Object
  extended by java.beans.FeatureDescriptor
      extended by atg.beans.SerializableFeatureDescriptor
          extended by atg.beans.DynamicPropertyDescriptor
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MetaProperty, RepositoryPropertyDescriptor

public class DynamicPropertyDescriptor
extends SerializableFeatureDescriptor

This class is used to describe an individual dynamic property accessible via a DynamicPropertyMapper. It is similar to PropertyDescriptor in spirit.

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String PORTABLE_VALUE_KEY
           
 
Fields inherited from class atg.beans.SerializableFeatureDescriptor
BUNDLE_ATTRIBUTE_NAME, LOCALE_ATTRIBUTE_NAME
 
Constructor Summary
DynamicPropertyDescriptor()
          Constructs a new DynamicPropertyDescriptor.
DynamicPropertyDescriptor(DynamicPropertyDescriptor pDesc)
          Constructs a DynamicPropertyDescriptor instance based on an existing DynamicPropertyDescriptor.
DynamicPropertyDescriptor(java.beans.PropertyDescriptor pDesc)
          Constructs a DynamicPropertyDescriptor instance based on a regular java.beans.PropertyDescriptor.
DynamicPropertyDescriptor(java.lang.String pPropertyName)
          Constructs a new DynamicPropertyDescriptor.
 
Method Summary
 java.beans.PropertyEditor createLocalePropertyEditor()
          Returns a new localized PropertyEditor instance that can edit this property for the default Locale.
 java.beans.PropertyEditor createLocalePropertyEditor(java.util.Locale pLocale)
          Returns a new localized PropertyEditor instance that can edit this property.
 java.beans.PropertyEditor createPropertyEditor()
          Returns a new PropertyEditor instance that can edit this property.
 DynamicBeanInfo getComponentPropertyBeanInfo()
          If this is a multi-valued property, this method returns the DynamicBeanInfo for an element of the property.
 java.lang.Class getComponentPropertyType()
           
 DynamicBeanInfo getPropertyBeanInfo()
          Get a DynamicBeanInfo describing the type of this property.
 java.lang.Class getPropertyEditorClass()
          The optional class of this property's PropertyEditor implementation.
 java.lang.Class getPropertyType()
          The Java type info for the property.
 java.beans.PropertyEditor getUIPropertyEditor()
          Returns a cached localized PropertyEditor instance for this DynamicPropertyDescriptor.
 boolean isMultiValued()
          Returns true if this property represents a multi-valued property.
 boolean isReadable()
          Returns property Readable
 boolean isRequired()
          Returns property Required
 boolean isWritable()
          Returns property Writable
 void setComponentPropertyType(java.lang.Class pComponentPropertyType)
          Sets the property ComponentPropertyType.
 void setPropertyEditorClass(java.lang.Class pPropertyEditorClass)
          Sets property PropertyEditorClass: the optional class of this property's PropertyEditor implementation.
 void setPropertyType(java.lang.Class pPropertyType)
          Sets property PropertyType: the class which this property can be expected to have at runtime.
 void setReadable(boolean pReadable)
          Sets property Readable -- indicates whether this dynamic property is readable.
 void setRequired(boolean pRequired)
          Sets property Required, indicating whether this dynamic property is required to be non-null in a valid object.
 void setWritable(boolean pWritable)
          Sets property Writable, indicating whether this dynamic property can be written.
 
Methods inherited from class atg.beans.SerializableFeatureDescriptor
copyFeatureDescriptor, getDisplayName, getDisplayNameResource, getDisplaySortString, getResourceBundle, getShortDescription, getShortDescriptionResource, getSortString, setDisplayNameResource, setShortDescriptionResource, toString
 
Methods inherited from class java.beans.FeatureDescriptor
attributeNames, getName, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

PORTABLE_VALUE_KEY

public static final java.lang.String PORTABLE_VALUE_KEY
See Also:
Constant Field Values
Constructor Detail

DynamicPropertyDescriptor

public DynamicPropertyDescriptor()
Constructs a new DynamicPropertyDescriptor.


DynamicPropertyDescriptor

public DynamicPropertyDescriptor(java.lang.String pPropertyName)
Constructs a new DynamicPropertyDescriptor.


DynamicPropertyDescriptor

public DynamicPropertyDescriptor(java.beans.PropertyDescriptor pDesc)
Constructs a DynamicPropertyDescriptor instance based on a regular java.beans.PropertyDescriptor.


DynamicPropertyDescriptor

public DynamicPropertyDescriptor(DynamicPropertyDescriptor pDesc)
Constructs a DynamicPropertyDescriptor instance based on an existing DynamicPropertyDescriptor.

Method Detail

setReadable

public void setReadable(boolean pReadable)
Sets property Readable -- indicates whether this dynamic property is readable.


isReadable

public boolean isReadable()
Returns property Readable


setWritable

public void setWritable(boolean pWritable)
Sets property Writable, indicating whether this dynamic property can be written.


isWritable

public boolean isWritable()
Returns property Writable


setRequired

public void setRequired(boolean pRequired)
Sets property Required, indicating whether this dynamic property is required to be non-null in a valid object. This is a hint to UIs that edit dynamic properties, to require a non-null value for this property.


isRequired

public boolean isRequired()
Returns property Required


createPropertyEditor

public java.beans.PropertyEditor createPropertyEditor()
Returns a new PropertyEditor instance that can edit this property.

For dynamic properties this approach is preferable to getPropertyEditorClass(), the corresponding method in java.beans.PropertyDescriptor, since the conversion methods and allowed values of dynamic properties may need to be determined at runtime.

This default implementation simply looks up in nucleus' property editor repository for the property editor for this class. Subclass DynamicPropertyDescriptor if the PropertyEditor depends on other information at runtime - i.e not just the getPropertyType method.


createLocalePropertyEditor

public java.beans.PropertyEditor createLocalePropertyEditor(java.util.Locale pLocale)
Returns a new localized PropertyEditor instance that can edit this property.

This differs from the above method in that the locale-specific editor can vary according to the given locale.

Parameters:
pLocale - the Locale for which the localized editor should be created, or null for the default locale.

createLocalePropertyEditor

public java.beans.PropertyEditor createLocalePropertyEditor()
Returns a new localized PropertyEditor instance that can edit this property for the default Locale.


getUIPropertyEditor

public final java.beans.PropertyEditor getUIPropertyEditor()
Returns a cached localized PropertyEditor instance for this DynamicPropertyDescriptor. This method is far more efficient than createLocalePropertyEditor(), and typically the sharing of the instance is not a problem for UI-event-driven applications without thread contention issues.


setPropertyType

public void setPropertyType(java.lang.Class pPropertyType)
Sets property PropertyType: the class which this property can be expected to have at runtime.


getPropertyType

public java.lang.Class getPropertyType()
The Java type info for the property. Unlike PropertyDescriptor, this will never describe a built-in Java type such as "int" since the DynamicPropertyMapper interface requires dynamic property values to be instances of java.lang.Object. In cases where the property value is a dynamic type, this method should return a valid static type for the value, using Object.class as a "least common denominator" last resort.


getPropertyBeanInfo

public DynamicBeanInfo getPropertyBeanInfo()
                                    throws java.beans.IntrospectionException
Get a DynamicBeanInfo describing the type of this property. In cases where a property value is a DynamicBean (for example, Hashtable), the Class returned by getPropertyType() is not capable of expressing all the known type information for the property. Therefore, this method exists to reflect on the property type without any intermediate references to a Class. It should be overridden by DynamicPropertyDescriptors that know about the property's dynamic type, to provide the appropriate DynamicBeanInfo.

By default, it returns a DynamicBeanInfo for the Class returned by getPropertyType(). Note: a DynamicPropertyDescriptor that has been subjected to serialization/deserialization must include enough state to permit this method to work.

Throws:
java.beans.IntrospectionException

getComponentPropertyBeanInfo

public DynamicBeanInfo getComponentPropertyBeanInfo()
                                             throws java.beans.IntrospectionException
If this is a multi-valued property, this method returns the DynamicBeanInfo for an element of the property.

By default, it returns the DynamicBeanInfo that corresponds to the class returned from getComponentPropertyType. If this is single valued property, this returns null. Note: a DynamicPropertyDescriptor that has been subjected to serialization/deserialization must include enough state to permit this method to work.

Throws:
java.beans.IntrospectionException

setPropertyEditorClass

public void setPropertyEditorClass(java.lang.Class pPropertyEditorClass)
Sets property PropertyEditorClass: the optional class of this property's PropertyEditor implementation.


getPropertyEditorClass

public java.lang.Class getPropertyEditorClass()
The optional class of this property's PropertyEditor implementation.


isMultiValued

public boolean isMultiValued()
Returns true if this property represents a multi-valued property. Arrays are always multi-valued. If a property descriptor provides a value for the ComponentPropertyType property, it too is considered multi valued.


setComponentPropertyType

public void setComponentPropertyType(java.lang.Class pComponentPropertyType)
Sets the property ComponentPropertyType. If this is a multi-valued property, this defines the class of the elements of that property.

Parameters:
pComponentPropertyType - new value to set

getComponentPropertyType

public java.lang.Class getComponentPropertyType()
Returns:
The value of the property ComponentPropertyType.