org.writersforge.catalan.process.properties
Class ChainedProperties

java.lang.Object
  extended byorg.writersforge.catalan.process.properties.BaseWorkProperties
      extended byorg.writersforge.catalan.process.properties.ChainedProperties
All Implemented Interfaces:
IWorkProperties
Direct Known Subclasses:
CommonProperties

public class ChainedProperties
extends BaseWorkProperties

A IWorkProperties that merges more than one IWorkProperties object into a chain of configurations. The ChainedProperties will search through each embedded config for the given property, and will return the first non-null value it finds. The array of property names is the union of all property names in all chained configs.

Author:
jsheets

Constructor Summary
ChainedProperties()
          Creates a new instance of ChainedProperties.
 
Method Summary
 void addPropertySet(IWorkProperties props)
          Adds the given IWorkProperties object to the end of the chain.
 java.lang.Object getProperty(java.lang.String name)
          Retrieves the value of a named config property from the chained IWorkProperties instances.
 java.lang.String[] getPropertyNames()
          Retrieves the names of all properties currently set on this holder.
 IWorkProperties[] getPropertySets()
          Retrieves an array of all chained IWorkProperties instances.
 java.lang.String toString()
          Converts object to String form.
 
Methods inherited from class org.writersforge.catalan.process.properties.BaseWorkProperties
asMap, asMap, getPropertyAsBoolean, getPropertyAsDatum, getPropertyAsMap, getPropertyAsNumber, getPropertyAsString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChainedProperties

public ChainedProperties()
Creates a new instance of ChainedProperties.

Method Detail

addPropertySet

public final void addPropertySet(IWorkProperties props)
Adds the given IWorkProperties object to the end of the chain. Configurations will be searched in the same order they are added.

Parameters:
props - IWorkProperties to chain

getPropertySets

public IWorkProperties[] getPropertySets()
Retrieves an array of all chained IWorkProperties instances.

Returns:
all properties

getPropertyNames

public java.lang.String[] getPropertyNames()
Retrieves the names of all properties currently set on this holder.

Returns:
array of all property names

getProperty

public java.lang.Object getProperty(java.lang.String name)
Retrieves the value of a named config property from the chained IWorkProperties instances. Returns the first non-null value it finds, searching in the order the chained configs were added.

Parameters:
name - property name
Returns:
the value of the property, or null if not set

toString

public java.lang.String toString()
Converts object to String form.

Overrides:
toString in class BaseWorkProperties
Returns:
object as String