com.sas.collection
Class CompositeProperties

com.sas.collection.CompositeProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class CompositeProperties

CompositeProperties is a subclass of Properties that aggregates multiple Properties objects. Objects of class Properties can already be chained together through their defaults field. This class, CompositeProperties, allows for multiple Properties objects to be added as defaults. In this way, a "tree" of CompositeProperties objects may be created. This class maintains a vector of defaults property objects, rather than a single defaults property object. When defaults are added to the CompositeProperties object, they are added at the head of the vector. When searching the tree for a particular property, a depth-first algorithm will be used, so that the last defaults added ( and it's defaults ) have priority over those added earlier. The defaults added may be of type CompositeProperties or its super class Properties.

See Also:
Serialized Form

Constructor Summary
CompositeProperties()
          Constructor.
CompositeProperties(java.util.Properties defaults)
          Constructor with initial value to add to defaults vector.
 
Method Summary
 void addDefaults(java.util.Properties defaults)
          Add to defaults vector.
 boolean containsKey(java.lang.String key)
          Test if specified key is found.
 java.lang.String getProperty(java.lang.String key)
          Search for the property with the specified key.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Search for the property with the specified key; return defaultValue if not found.
 void list(java.io.PrintStream out)
          Print the property list out to the specified output stream.
 void list(java.io.PrintWriter out)
          Print the property list out to the specified output stream.
 java.util.Enumeration propertyNames()
          Return an Enumeration of property names, including those contained in the defaults vector.
 java.lang.Object remove(java.lang.Object key)
          Remove a property, given its name.
 void removeAllProperties()
          Remove all the properties.
 int size()
          Count the number of properties, including those contained in the defaults vector.
 

Constructor Detail

CompositeProperties

public CompositeProperties()
Constructor.


CompositeProperties

public CompositeProperties(java.util.Properties defaults)
Constructor with initial value to add to defaults vector.

Method Detail

addDefaults

public void addDefaults(java.util.Properties defaults)
Add to defaults vector.


propertyNames

public java.util.Enumeration propertyNames()
Return an Enumeration of property names, including those contained in the defaults vector.

Overrides:
propertyNames in class java.util.Properties

getProperty

public java.lang.String getProperty(java.lang.String key)
Search for the property with the specified key.

Overrides:
getProperty in class java.util.Properties

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Search for the property with the specified key; return defaultValue if not found.

Overrides:
getProperty in class java.util.Properties

containsKey

public boolean containsKey(java.lang.String key)
Test if specified key is found.


size

public int size()
Count the number of properties, including those contained in the defaults vector.

Specified by:
size in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
size in class java.util.Hashtable<java.lang.Object,java.lang.Object>

remove

public java.lang.Object remove(java.lang.Object key)
Remove a property, given its name. This will attempt to remove all occurrences of the given name in the tree of Properties objects. The object returned will be the value associated with the first key match found.

Specified by:
remove in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
remove in class java.util.Hashtable<java.lang.Object,java.lang.Object>

removeAllProperties

public void removeAllProperties()
Remove all the properties.


list

public void list(java.io.PrintStream out)
Print the property list out to the specified output stream.

Overrides:
list in class java.util.Properties

list

public void list(java.io.PrintWriter out)
Print the property list out to the specified output stream.

Overrides:
list in class java.util.Properties



Copyright © 2009 SAS Institute Inc. All Rights Reserved.