planetj.property
Class PropertyGroupReader

java.lang.Object
  |
  +--planetj.property.PropertyGroupReader

public class PropertyGroupReader
extends Object

Provides methods for translating between properties specified as text, and a collection of PropertyGroup objects. Properties should be encoded as text in the following format:

GroupA {
name1: value1;
name2: value2A, value2B, value2C;
name3: value3A, value3B;
}

GroupA {
name1: value1B;
name2: value2B, value2D, value2E;
name4: value4A;
}

GroupB {
name5: value5A, value5B; name6: value6;
}

Notice that there can be multiple property groups of the same name - in this case there are two GroupA property groups defined. Each a property can either have a single value, or a comma separated list of values. Both properties and names are case sensitive. Whitespace is ignored in the formatting, although both property names and values may include whitespace characters.


Method Summary
 PropertyGroupList readProperties(String pText)
          Reads properties from the String, translates them into PropertyGroup objects, and puts them into a List.
 Class registerPropertyGroup(String pName, Class pClass)
          Associates a sublcass of PropertyGroup with a name.
static PropertyGroupReader singleton()
          Gets the singleton instance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readProperties

public PropertyGroupList readProperties(String pText)
                                 throws CMException
Reads properties from the String, translates them into PropertyGroup objects, and puts them into a List.

Returns:
A PropertyGroupList containing PropertyGroup objects corresponding to the properties defined in the String
CMException

registerPropertyGroup

public Class registerPropertyGroup(String pName,
                                   Class pClass)
Associates a sublcass of PropertyGroup with a name. When a group of properties being read has the specified name, those properties will be stored in the specified subclass of PropertyGroup. If a group of properties is read which is not associated with any name, they are stored in an instance of DefaultPropertyGroup.

Returns:
The previous class which was mapped to this name is returned.

singleton

public static PropertyGroupReader singleton()
Gets the singleton instance