com.sas.util
Class DynamicPropertyBag

com.sas.util.DynamicPropertyBag
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.collection.PropertyBagChangedSource, com.sas.collection.PropertyBagInterface, com.sas.collection.StaticPropertyBagInterface, com.sas.ComponentInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.PropertyValueQueryInterface, com.sas.PublicClonable, com.sas.util.Countable, DynamicBeanInfoInterface, UserCodeGenClassInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
ParameterBag

public abstract class DynamicPropertyBag
implements DynamicBeanInfoInterface, com.sas.PropertyValueQueryInterface, UserCodeGenClassInterface, com.sas.collection.PropertyBagInterface

This abstract class represents a property bag component, which defines a collection of dynamic properties that can be specified at design time within the IDE via a customizer.

See Also:
PropertyBag, Serialized Form

Constructor Summary
DynamicPropertyBag()
          Create a new DynamicPropertyBag
 
Method Summary
 void addPropertyBagChangedListener(com.sas.collection.PropertyBagChangedListener listener)
          Add a listener for the com.sas.collection.PropertyBagChangedEvent event.
 java.lang.Object clone()
          Clone a dynamic property bag.
 boolean containsKey(java.lang.String key)
          Determine if the property bag contains a property with this name (key).
 int count()
          Return the number of properties in the property bag.
 java.lang.Object get(java.lang.String key)
          Get an item from a property bag.
 java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
          Get an item from a property bag, or return a default if it does not exist.
 java.beans.BeanInfo getBeanInfo()
          Retrieve information about this object's properties, exposed methods, and events.
 java.lang.Class getPropertyType(java.lang.Object bean, java.lang.String property)
          Return the type of the specified property.
 java.lang.Object getPropertyValue(java.lang.Object bean, java.lang.String property)
          Return the value of the property specified.
 java.lang.String[] listKeys()
          Return a list of the keys for this property bag.
 void merge(com.sas.collection.StaticPropertyBagInterface other)
          Merge into this bag any property from the source which does not exist in this bag.
 void remove(java.lang.String key)
          Remove a property from the property bag.
 void removeAll()
          Remove all items from the property bag.
 void removePropertyBagChangedListener(com.sas.collection.PropertyBagChangedListener listener)
          Remove a listener for the com.sas.collection.PropertyBagChangedEvent event.
 void set(com.sas.collection.StaticPropertyBagInterface other)
          Add the contents of another property bag to this property bag.
 void set(java.lang.String key, java.lang.Object property)
          Put a property in the property bag.
 void setPropertyValue(java.lang.Object bean, java.lang.String property, java.lang.Object value)
          Set the value of the specified property.
 com.sas.collection.DictionaryInterface toDictionary(com.sas.collection.DictionaryInterface initialDictionary)
          Place the property bag items into a dictionary and return that dictionary.
 
Methods inherited from interface com.sas.util.DynamicBeanInfoInterface
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.sas.util.UserCodeGenClassInterface
getUserCodeGenClass
 

Constructor Detail

DynamicPropertyBag

public DynamicPropertyBag()
Create a new DynamicPropertyBag

Method Detail

getBeanInfo

public java.beans.BeanInfo getBeanInfo()
Retrieve information about this object's properties, exposed methods, and events.

Specified by:
getBeanInfo in interface DynamicBeanInfoInterface
Returns:
A BeanInfo object describing the object

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object bean,
                                         java.lang.String property)
Return the value of the property specified.

Specified by:
getPropertyValue in interface com.sas.PropertyValueQueryInterface
Parameters:
bean - The bean to get the property value from.
property - The name of the property to return the value of.
Returns:
The value of the property.

setPropertyValue

public void setPropertyValue(java.lang.Object bean,
                             java.lang.String property,
                             java.lang.Object value)
Set the value of the specified property.

Specified by:
setPropertyValue in interface com.sas.PropertyValueQueryInterface
Parameters:
bean - The bean to set the property value on.
property - The name of the property to set the value of.
value - The new value of the property.

getPropertyType

public java.lang.Class getPropertyType(java.lang.Object bean,
                                       java.lang.String property)
Return the type of the specified property.

Specified by:
getPropertyType in interface com.sas.PropertyValueQueryInterface
Parameters:
bean - The bean which has the property.
property - The name of the property to get the type of.
Returns:
The type of the property.

count

public int count()
Return the number of properties in the property bag.

Specified by:
count in interface com.sas.collection.StaticPropertyBagInterface
Specified by:
count in interface com.sas.util.Countable
Returns:
the number of properties in the property bag.

containsKey

public boolean containsKey(java.lang.String key)
Determine if the property bag contains a property with this name (key).

Specified by:
containsKey in interface com.sas.collection.StaticPropertyBagInterface
Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use aString.intern() to create an interned string.)
Returns:
true if the property bag contains the property.

get

public java.lang.Object get(java.lang.String key)
Get an item from a property bag.

Specified by:
get in interface com.sas.collection.StaticPropertyBagInterface
Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use aString.intern() to create an interned string.)
Returns:
the object associated with the key
Throws:
java.util.NoSuchElementException - if there is no such property in the property bag. (this is necessary to distinguish between no such key and a property value of null.)

get

public java.lang.Object get(java.lang.String key,
                            java.lang.Object defaultValue)
Get an item from a property bag, or return a default if it does not exist.

Specified by:
get in interface com.sas.collection.StaticPropertyBagInterface
Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use aString.intern() to create an interned string.)
defaultValue - a default value to return if the named property does not exist in the property bag
Returns:
the object associated with the key, or the defaultValue if the bag does not contain an element for the specified key.

toDictionary

public com.sas.collection.DictionaryInterface toDictionary(com.sas.collection.DictionaryInterface initialDictionary)
Place the property bag items into a dictionary and return that dictionary.

Specified by:
toDictionary in interface com.sas.collection.StaticPropertyBagInterface
Parameters:
initialDictionary - a dictionary into which the property bag places all of its values via. This may be null, in which case a new Dictionary is created.
Returns:
the dictionary containing the property bag contents.
See Also:
Dictionary, DictionaryInterface.set(Object,Object)

listKeys

public java.lang.String[] listKeys()
Return a list of the keys for this property bag.

Specified by:
listKeys in interface com.sas.collection.StaticPropertyBagInterface
Returns:
an array containing the property keys
See Also:
StringCollection

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone a dynamic property bag.

Specified by:
clone in interface com.sas.collection.StaticPropertyBagInterface
Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class com.sas.Component
Returns:
a clone of the dynamic property bag
Throws:
java.lang.CloneNotSupportedException - if the object cannot be cloned.

set

public void set(java.lang.String key,
                java.lang.Object property)
Put a property in the property bag.

Specified by:
set in interface com.sas.collection.PropertyBagInterface
Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use aString.intern() to create an interned string.)
property - the value to associate with the property name Property values may be null.

remove

public void remove(java.lang.String key)
Remove a property from the property bag. After removing, contains(key) will return false and get(key) will throw a NoSuchElementException

Specified by:
remove in interface com.sas.collection.PropertyBagInterface
Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use aString.intern() to create an interned string.)
Throws:
java.util.NoSuchElementException - if the bag does not contains the named element.

removeAll

public void removeAll()
Remove all items from the property bag.

Specified by:
removeAll in interface com.sas.collection.PropertyBagInterface

set

public void set(com.sas.collection.StaticPropertyBagInterface other)
Add the contents of another property bag to this property bag. This does set(key, property) on this property bag for each the key/property pair from the source.

Specified by:
set in interface com.sas.collection.PropertyBagInterface
Parameters:
other - another property bag
See Also:
PropertyBagInterface.merge(com.sas.collection.StaticPropertyBagInterface)

merge

public void merge(com.sas.collection.StaticPropertyBagInterface other)
Merge into this bag any property from the source which does not exist in this bag. For items which exists in both property bags, if both items are also property bags, merge the element from other into the element from this PropertyBag recursively.

Specified by:
merge in interface com.sas.collection.PropertyBagInterface
Parameters:
other - another property bag
See Also:
PropertyBagInterface.set(com.sas.collection.StaticPropertyBagInterface)

addPropertyBagChangedListener

public void addPropertyBagChangedListener(com.sas.collection.PropertyBagChangedListener listener)
Add a listener for the com.sas.collection.PropertyBagChangedEvent event.

Specified by:
addPropertyBagChangedListener in interface com.sas.collection.PropertyBagChangedSource
Parameters:
listener - an object which handles PropertyBagChangedEvent events the listener is not added a second time if it already exists in the list of listeners for this event.
See Also:
PropertyBagChangedSource

removePropertyBagChangedListener

public void removePropertyBagChangedListener(com.sas.collection.PropertyBagChangedListener listener)
Remove a listener for the com.sas.collection.PropertyBagChangedEvent event. Nothing happens if the listener is not in the list of listeners for this event.

Specified by:
removePropertyBagChangedListener in interface com.sas.collection.PropertyBagChangedSource
Parameters:
listener - an object which handles PropertyBagChangedEvent events
See Also:
PropertyBagChangedSource



Copyright © 2009 SAS Institute Inc. All Rights Reserved.