org.ceryle.xml
Class HistoryManager

java.lang.Object
  extended by org.ceryle.xml.HistoryManager

public class HistoryManager
extends Object

Uses an XMLProcessor to provide access to a simple XML properties file that can be queried for named string lists. Similar to org.ceryle.xml.PropertyManager, each <property> element contains a name and value. The difference here is that the value is read or written as an Iterator containing zero or more Strings rather than a single value. For example:

     <property name="findHistory">
         <value>http://purl.org/ceryle/index.html</value>
         <value>http://www.google.com/</value>
     </property>
     ...
 

Since:
JDK1.3
Version:
$Id: HistoryManager.java,v 3.13 2007-06-15 12:10:28 altheim Exp $
Author:
Murray Altheim
See Also:
XMLProcessor

Field Summary
static String propElement
          The name of the XML property element.
static String propNameAttr
          The name of the XML property name attribute.
static String propValueElement
          The name of the XML property value attribute.
static String rootElement
          The name of the XML root/document element.
 
Constructor Summary
HistoryManager(MessageHandler mh, XMLProcessor xp, String filename)
          Constructor provided a String filename containing the pathname of the preferences file.
 
Method Summary
 boolean isDirty()
          Returns true if any properties have been modified since import of the history file.
 Iterator readProperty(String name)
          Returns an Iterator (over a collection of Strings) as the value corresponding to the property name, null if unavailable or empty.
 void writeHistory(String filename)
          Writes the current history document to a File named filename.
 boolean writeProperty(String name, Iterator values)
          Writes the property of String name with an Iterator value to the history file, returning true if the property replaced an existing value, false if the property did not exist prior.
 boolean writeProperty(String name, Object value)
          Writes the property of String name with an Object value to the history file, returning true if the property replaced an existing value, false if the property did not exist prior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootElement

public static String rootElement
The name of the XML root/document element. Default is "history".


propElement

public static String propElement
The name of the XML property element. Default is "property".


propNameAttr

public static String propNameAttr
The name of the XML property name attribute. Default is "name".


propValueElement

public static String propValueElement
The name of the XML property value attribute. Default is "value".

Constructor Detail

HistoryManager

public HistoryManager(MessageHandler mh,
                      XMLProcessor xp,
                      String filename)
               throws FileNotFoundException,
                      ProcessException
Constructor provided a String filename containing the pathname of the preferences file. Each named preference shows up as PCDATA content in a like-named element. Following construction, the parse takes place, then the HistoryManager object can be queried for individual properties.

Throws:
FileNotFoundException
ProcessException
Method Detail

readProperty

public Iterator readProperty(String name)
Returns an Iterator (over a collection of Strings) as the value corresponding to the property name, null if unavailable or empty. Note that this performs whitespace trimming.


writeProperty

public boolean writeProperty(String name,
                             Object value)
                      throws ProcessException
Writes the property of String name with an Object value to the history file, returning true if the property replaced an existing value, false if the property did not exist prior. The value can either be a String or its toString() method will be called to provide a value. If the String value contains any markup characters, the contents will be written as a CDATA section.

Throws:
ProcessException

writeProperty

public boolean writeProperty(String name,
                             Iterator values)
                      throws ProcessException
Writes the property of String name with an Iterator value to the history file, returning true if the property replaced an existing value, false if the property did not exist prior. Individual values from the Iterator are either Strings themselves or their toString() method will be called to provide a value. If they contain any markup characters, they will be written as CDATA sections.

Throws:
ProcessException

writeHistory

public void writeHistory(String filename)
Writes the current history document to a File named filename. If no history document has been generated, this method does nothing.


isDirty

public boolean isDirty()
Returns true if any properties have been modified since import of the history file.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.