com.plumtree.openfoundation.util
Class XPPropertyBag

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPPropertyBag
All Implemented Interfaces:
IXPPropertyBag

public class XPPropertyBag
extends java.lang.Object
implements IXPPropertyBag

Note that we do not maintain a copy of the Xerces XML persistence object, since it can be a large object (50k+) and cause memory overflow during large crawls (issue 26142).
This object can serialize itself to and from XML. The format it uses is simple: 1. The root element is names "PTBAG" with an attribute "V" which indicates the Plumtree propertybag version # (1.1) and the standard attribute "XML-SPACE" set to "preserve". (This is required to save leading and trailing spaces as well as tabs and CR-LFs.). XML-SPACE is specific to MSXML and should really be xml:space going forward. Our parsing needs to maintain backwards compatibility. 2. Each sub element is one of "I" (integer), "D" (date), "F" (float), "A" (array), or "O" (object). Each subelement has an attribute "N" which is the name of the element. Subelements at a given level should have a unique property name with no trailing or leading spaces. 3. The "O" element type is special and indicates an object which is simply a property bag itself. The structure is essentially recursive and the same as the root except for the name. 4. The "A" child elements have the same structure as a propertybag, but has a set of required child elements and stores array values. The name of each field is a comma-delimited list of array indices (eg, "1,2,3"). The size of each dimension is also stored as "MAX#" where "#" is the dimension. The number of dimensions is stored as "DIMS". The array can have multiple dimensions. Each dimension should have at least one field. 5. Note that date properties will be serialized in a standard format "MM/DD/YYYY H:M:S", not the localized format. 6. There is currently no DTD. 7. Property names are not case-sensitive. 8. Floats should be represented as US English encoded strings. That is, the decimal point should be used instead of a comma as in Europe. Example: Microsoft web site A pointer to Microsoft's web site. 101 9.5 9/18/1998 14:03:49 2 2 1 23 24 25 The 1st name The 2nd name The 3rd name MSN web site A pointer to MSN's web site. 1001


Constructor Summary
XPPropertyBag()
          Creates a new XPPropertyBag object.
 
Method Summary
 IXPPropertyBag Clone()
          Clone a property bag.
 boolean Compare(IXPPropertyBag propBag)
          IPTPropertyBag version of Compare.
 int GetCount()
          Returns the count of elements in the property bag.
 IXPEnumerator GetEnumerator()
          Returns Enumerator for XPPropertyBag.
 IXPEnumerator GetKeys()
          GetKeys returns an enumerator of the keys in the PropertyBag.
 void LoadFromBinary(byte[] xml)
          LoadFromBinary.
 void LoadFromFile(java.lang.String fileName)
          LoadFromFile.
 void LoadFromInputStream(XPInputStream stream)
          Loads the property bag interpreting Input Stream.
 void LoadFromXML(java.lang.String xmlString)
          LoadFromXML.
 double ReadAsDouble(java.lang.String property)
          Retrieve an individual property value by name.
 int ReadAsInt(java.lang.String property)
          Retrieve an individual property value by name.
 IXPPropertyBag ReadAsIXPPropertyBag(java.lang.String property)
          Retrieve an individual property value by name.
 java.lang.Object ReadAsObject(java.lang.String property)
          Retrieve an individual property value by name.
 java.lang.Object[] ReadAsObject1DArray(java.lang.String property)
          Returns the value to which the specified key is mapped in this hashtable.
 java.lang.Object[][] ReadAsObject2DArray(java.lang.String property)
          Returns the value to which the specified key is mapped in this hashtable.
 java.lang.String ReadAsString(java.lang.String property)
          Returns the String value of the object stored under the specified property, rendered via toString(), or null if no value is present for that property name.
 XPDateTime ReadAsXPDateTime(java.lang.String property)
          Retrieve an individual property value by name.
 void Remove(java.lang.String property)
          Remove.
 void RemoveAll()
          Removes All Elements.
 byte[] SaveToBinary(int xmlFormat)
          Saves Property bag values in binary format.
 void SaveToFile(java.lang.String fileName)
          Saves Property bag values to the given file.
 java.lang.String SaveToXML(int xmlFormat)
          Saves the Property Bag values into XML format.
 java.lang.String toString()
          Deprecated. Use ToString()
 java.lang.String ToString()
          Converts Propertybag values into String.
 void Write(java.lang.String property, double _value)
          Set/add an individual property value by name.
 void Write(java.lang.String property, int _value)
          Set/add an individual property value by name.
 void Write(java.lang.String property, IXPPropertyBag _value)
          Set/add an individual property value by name.
 void Write(java.lang.String property, java.lang.Object _value)
          Write.
 void Write(java.lang.String property, java.lang.Object[] _value)
          Write.
 void Write(java.lang.String property, java.lang.Object[][] _value)
          Write.
 void Write(java.lang.String property, java.lang.String _value)
          Set/add an individual property value by name.
 void Write(java.lang.String property, XPDateTime _value)
          Set/add an individual property value by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPPropertyBag

public XPPropertyBag()
Creates a new XPPropertyBag object.

Method Detail

Clone

public IXPPropertyBag Clone()
Clone a property bag.

Specified by:
Clone in interface IXPPropertyBag
Returns:
The cloned bag

Compare

public boolean Compare(IXPPropertyBag propBag)
IPTPropertyBag version of Compare.

Specified by:
Compare in interface IXPPropertyBag
Parameters:
propBag - an IXPPropertyBag object.
Returns:
int result of comparison (1 if equal, 0 if false)

GetCount

public int GetCount()
Returns the count of elements in the property bag.

Specified by:
GetCount in interface IXPPropertyBag
Returns:
a int value indicating the count of elements in the property bag

GetEnumerator

public IXPEnumerator GetEnumerator()
Description copied from interface: IXPPropertyBag
Returns Enumerator for XPPropertyBag.

Specified by:
GetEnumerator in interface IXPPropertyBag
Returns:
Enumerator for XPPropertyBag.

GetKeys

public IXPEnumerator GetKeys()
GetKeys returns an enumerator of the keys in the PropertyBag. This can be used to iterate through the items in the PropertyBag.

Returns:
the IXPEnumerator

LoadFromBinary

public void LoadFromBinary(byte[] xml)
Description copied from interface: IXPPropertyBag
LoadFromBinary. Initializes the property bag from a binary XML format.

Specified by:
LoadFromBinary in interface IXPPropertyBag
Parameters:
xml - Input Binary to load XML from.

LoadFromFile

public void LoadFromFile(java.lang.String fileName)
Description copied from interface: IXPPropertyBag
LoadFromFile. Load this PropertyBag from a text file.

Specified by:
LoadFromFile in interface IXPPropertyBag
Parameters:
fileName - to Load From.

LoadFromXML

public void LoadFromXML(java.lang.String xmlString)
Description copied from interface: IXPPropertyBag
LoadFromXML. Initializes the property bag from a string-ized XML format.

Specified by:
LoadFromXML in interface IXPPropertyBag
Parameters:
xmlString - XML in String Format as input.

LoadFromInputStream

public void LoadFromInputStream(XPInputStream stream)
Loads the property bag interpreting Input Stream.

Parameters:
stream - XPInputStream or a subclass of it.

ReadAsDouble

public double ReadAsDouble(java.lang.String property)
Description copied from interface: IXPPropertyBag
Retrieve an individual property value by name.

Specified by:
ReadAsDouble in interface IXPPropertyBag
Parameters:
property - Property Value to be read as String.
Returns:
double value

ReadAsInt

public int ReadAsInt(java.lang.String property)
Description copied from interface: IXPPropertyBag
Retrieve an individual property value by name.

Specified by:
ReadAsInt in interface IXPPropertyBag
Parameters:
property - Property Value to be read as int.
Returns:
a int value.

ReadAsIXPPropertyBag

public IXPPropertyBag ReadAsIXPPropertyBag(java.lang.String property)
Description copied from interface: IXPPropertyBag
Retrieve an individual property value by name.

Specified by:
ReadAsIXPPropertyBag in interface IXPPropertyBag
Parameters:
property - Property Value to be read as String.
Returns:
IXPPropertyBag implementations.

ReadAsObject

public java.lang.Object ReadAsObject(java.lang.String property)
Description copied from interface: IXPPropertyBag
Retrieve an individual property value by name.

Specified by:
ReadAsObject in interface IXPPropertyBag
Parameters:
property - Property Value to be read as String.
Returns:
Object.

ReadAsObject1DArray

public java.lang.Object[] ReadAsObject1DArray(java.lang.String property)
Returns the value to which the specified key is mapped in this hashtable. the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

Specified by:
ReadAsObject1DArray in interface IXPPropertyBag
Parameters:
property - Property Name.
Returns:
2D Object Array containing all the values of above named property.

ReadAsObject2DArray

public java.lang.Object[][] ReadAsObject2DArray(java.lang.String property)
Returns the value to which the specified key is mapped in this hashtable. the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

Specified by:
ReadAsObject2DArray in interface IXPPropertyBag
Parameters:
property - Property Name.
Returns:
2D Object Array containing all the values of above named property.

ReadAsString

public java.lang.String ReadAsString(java.lang.String property)
Returns the String value of the object stored under the specified property, rendered via toString(), or null if no value is present for that property name.

Specified by:
ReadAsString in interface IXPPropertyBag
Parameters:
property - Property Value to be read as String.
Returns:
Retrieve an individual property String.

ReadAsXPDateTime

public XPDateTime ReadAsXPDateTime(java.lang.String property)
Description copied from interface: IXPPropertyBag
Retrieve an individual property value by name.

Specified by:
ReadAsXPDateTime in interface IXPPropertyBag
Parameters:
property - XPDateTime Value to be read as String.
Returns:
XPDateTime.

Remove

public void Remove(java.lang.String property)
Description copied from interface: IXPPropertyBag
Remove. Remove an individual property value by name.

Specified by:
Remove in interface IXPPropertyBag
Parameters:
property - to be removed.

RemoveAll

public void RemoveAll()
Description copied from interface: IXPPropertyBag
Removes All Elements.

Specified by:
RemoveAll in interface IXPPropertyBag

SaveToBinary

public byte[] SaveToBinary(int xmlFormat)
Saves Property bag values in binary format.

Specified by:
SaveToBinary in interface IXPPropertyBag
Parameters:
xmlFormat - is input.
Returns:
Byte array containing Property bag values.

SaveToFile

public void SaveToFile(java.lang.String fileName)
Saves Property bag values to the given file.

Specified by:
SaveToFile in interface IXPPropertyBag
Parameters:
fileName - to which Property bag should be written.

SaveToXML

public java.lang.String SaveToXML(int xmlFormat)
Saves the Property Bag values into XML format.

Specified by:
SaveToXML in interface IXPPropertyBag
Parameters:
xmlFormat - Type of XMLFormat.
Returns:
String value containing Propertybag in XMLFormat.

ToString

public java.lang.String ToString()
Converts Propertybag values into String.

Returns:
PropertyBag values as String.

toString

public java.lang.String toString()
Deprecated. Use ToString()

XPPropertyBag toString() function.

Returns:
this bag as a string.
Throws:
XPException - if problem

Write

public void Write(java.lang.String property,
                  double _value)
Description copied from interface: IXPPropertyBag
Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as double.

Write

public void Write(java.lang.String property,
                  int _value)
Description copied from interface: IXPPropertyBag
Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as int

Write

public void Write(java.lang.String property,
                  IXPPropertyBag _value)
Description copied from interface: IXPPropertyBag
Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as IXPPropertyBag.

Write

public void Write(java.lang.String property,
                  java.lang.Object _value)
Description copied from interface: IXPPropertyBag
Write. Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as Object.

Write

public void Write(java.lang.String property,
                  java.lang.Object[] _value)
Description copied from interface: IXPPropertyBag
Write. Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as Object Array.

Write

public void Write(java.lang.String property,
                  java.lang.Object[][] _value)
Description copied from interface: IXPPropertyBag
Write. Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as 2D Object Array.

Write

public void Write(java.lang.String property,
                  java.lang.String _value)
Description copied from interface: IXPPropertyBag
Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as String.

Write

public void Write(java.lang.String property,
                  XPDateTime _value)
Description copied from interface: IXPPropertyBag
Set/add an individual property value by name.

Specified by:
Write in interface IXPPropertyBag
Parameters:
property - Property name as String.
_value - Property Value as XPDateTime.


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.