com.alien.enterpriseRFID.util
Class XMLReader

java.lang.Object
  extended bycom.alien.enterpriseRFID.util.XMLReader

public class XMLReader
extends java.lang.Object

This is a simple XML reader that reads supplied XML text and parses its contents into a HashTable. It will only read one level of tags deep, and performs all reads in memory, so XML file size is somewhat limited. Results are returned as a Hashtable of tag-value pairs.

Given the following XML:

   Hello
   
     Wow
   
 
The result will be a 2-entry hashtable of:
   TAG = Hello
   One = Wow
 

Call this class repeatedly to dive down into multi-layer trees. To read:

   
     Chris
     today
   
 
Call the class once, to return a Hashtable of:
   TAG = "Chris
          today"
 
and then call the class again on the results to resolve individual entries.

Version:
1.3 Sep 2005
Author:
David Krull

Constructor Summary
XMLReader(java.lang.String string)
          Construct a new XMLReader to read and parse XML data from a String.
 
Method Summary
 java.lang.String getXMLString()
          Returns the XML string data being parsed.
 java.util.Hashtable readXML()
          Scans the entire XML string, parsing its elements into a Hashtable.
 java.util.Hashtable readXML(java.util.Hashtable hashtable)
          Read entire XML into a given Hashtable.
 boolean readXMLNode(java.util.Hashtable hashtable)
          Reads and parses a single XML node into a Hashtable.
 void setXMLString(java.lang.String XMLString)
          Sets the XML string to be parsed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLReader

public XMLReader(java.lang.String string)
Construct a new XMLReader to read and parse XML data from a String.

Parameters:
string - the string to read XML data from
Method Detail

getXMLString

public java.lang.String getXMLString()
Returns the XML string data being parsed.

Returns:
XML string data being parsed

setXMLString

public void setXMLString(java.lang.String XMLString)
Sets the XML string to be parsed.

Parameters:
XMLString - the XML data to parse

readXML

public java.util.Hashtable readXML()
                            throws java.text.ParseException
Scans the entire XML string, parsing its elements into a Hashtable. The keys of the HashTable are the elements of the XML, and the values of the Hasttable are the contents of each tag element.

Returns:
a Hashtable containing the parsed contents of the XML file
Throws:
java.text.ParseException - if XML is invalid

readXML

public java.util.Hashtable readXML(java.util.Hashtable hashtable)
                            throws java.text.ParseException
Read entire XML into a given Hashtable.

Parameters:
hashtable - a Hasttable to read the data into
Returns:
a Hashtable containing the XML file contents
Throws:
java.text.ParseException - is XML is invalid

readXMLNode

public boolean readXMLNode(java.util.Hashtable hashtable)
                    throws java.text.ParseException
Reads and parses a single XML node into a Hashtable.

Parameters:
hashtable - the Hashtable to read the single node into
Returns:
true if there are more nodes to read, false otherwise
Throws:
java.text.ParseException - if XML is invalid or the hashtable is null