com.sas.collection
Interface PropertyBagInterface

All Superinterfaces:
java.lang.Cloneable, com.sas.util.Countable, PropertyBagChangedSource, com.sas.PublicClonable, StaticPropertyBagInterface
All Known Subinterfaces:
RangeSegmentInterface
All Known Implementing Classes:
BorderStyle, CellStyle, CellVectorStyle, ColumnStyle, DynamicPropertyBag, FontStyle, NodeStyle, ParameterBag, PropertyBag, RangeSegment, RowStyle, TextElement

public interface PropertyBagInterface
extends StaticPropertyBagInterface

A PropertyBagInterface defines a set of properties, much like a Dictionary but simpler: keys must be Strings. Abstractly, a PropertyBag is like a Java Bean with a set of dynamic as opposed to fixed properties. The set of properties on an instance can change over time.

A property bag is an implementation of the Variable State pattern from Kent Beck's book, Smalltalk Best Practices Patterns. The property bag is intended to be used as part of the internal implementation of a higher level object that has variable state, i.e. one whose set of properties changes over time. The property bag manages that set of variable properties in a consistent way.

Abstractly, a property bag is like a Java Bean with a set of dynamic as opposed to fixed properties. The set of properties on an instance can change over time. The property bag sends PropertyBagChangedEvents when a property is added, removed, replaced, or when that property value changes its state, provided that object also sends PropertyChangeEvents or PropertyBagChangedEvents (for example, the property may be another PropertyBag).

This interface extends the com.sas.collection.StaticPropertyBagInterface, which provides the read-only methods for accessing a property bag. This interface adds the update methods.

See Also:
StaticPropertyBagInterface, PropertyBag, DictionaryInterface

Method Summary
abstract  void merge(StaticPropertyBagInterface other)
          Merge into this bag any property from the source property bag which does not exist in this bag.
abstract  void remove(java.lang.String key)
          Remove a property from this property bag.
abstract  void removeAll()
          Remove all items from this property bag.
abstract  void set(StaticPropertyBagInterface other)
          Add the contents of another property bag to this property bag.
abstract  void set(java.lang.String key, java.lang.Object property)
          Put a property in this property bag.
 
Methods inherited from interface com.sas.collection.StaticPropertyBagInterface
clone, containsKey, count, get, get, listKeys, toDictionary
 
Methods inherited from interface com.sas.collection.PropertyBagChangedSource
addPropertyBagChangedListener, removePropertyBagChangedListener
 

Method Detail

set

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

Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use key.intern() to create an interned string. Note that Java String literals are automatically interned, so you need not do "constant".intern())
property - the value to associate with the property name. Property values may be null.

remove

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

Parameters:
key - the name of the property. This string must be an interned string and may not be null. (Use key.intern() to create an interned string. Note that Java String literals are automatically interned, so you need not do "constant".intern())
Throws:
java.util.NoSuchElementException - if the bag does not contains the named element.

removeAll

void removeAll()
Remove all items from this property bag.


set

void set(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.

Parameters:
other - another property bag
See Also:
merge(com.sas.collection.StaticPropertyBagInterface)

merge

void merge(StaticPropertyBagInterface other)
Merge into this bag any property from the source property bag 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 property bag recursively.

Parameters:
other - another property bag
See Also:
set(com.sas.collection.StaticPropertyBagInterface)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.