com.adventnet.utilities.xml.dom
Class XMLDataReader

java.lang.Object
  |
  +--com.adventnet.utilities.xml.dom.XMLDataReader

public class XMLDataReader
extends java.lang.Object
implements java.io.Serializable

This class uses the Micorsoft-DataChannel's XML parser to read data from an XML file and constructs the XMLNode tree.

It loads the XML file using the specified URL and constructs the XMLNode tree by creating an XMLNode object for each Element/Comment/PCDATA/CDATA/Entity object in the XML file. Using the parentNode and childNodeList references in the XMLNode object, the elements are linked together to form the tree.

To facilitate quick search for a particular element, and to uniquely identify each element it relies on each element having an ID attribute with a unique value.

See Also:
com.adventnet.utils.xml.XMLNode, Serialized Form

Field Summary
static int APPLICATION
           
(package private)  boolean doValidate
           
static int EJB_APPLICATION
           
 
Constructor Summary
XMLDataReader()
          When invoking this constructor, the user will need to follow it up by explicitly calling the load(String) method.
XMLDataReader(java.io.InputStream istream)
          This constructor will load the specified XML from the InputStream and constructs the XMLNode tree.
XMLDataReader(java.io.InputStream inputStream, int applicationType)
          The XMLDataReader which reads from the given InputStream.
XMLDataReader(java.io.InputStream istream, java.lang.String ClassNameForXMLNode)
          This Constructor will load the specified XML from the InputStream and and constructs the XMLNode tree.
XMLDataReader(java.lang.String urlString)
          This constructor will load the specified XML file and constructs the XMLNode tree.
XMLDataReader(java.lang.String fileName, boolean isUrl)
          This constructor will load the specified XML file and constructs the XMLNode tree.
XMLDataReader(java.lang.String fileName, boolean isUrl, boolean doValidate)
          This constructor will load the specified XML file and constructs the XMLNode tree.
XMLDataReader(java.lang.String fileName, boolean isUrl, boolean doValidate, org.xml.sax.ErrorHandler errHandler)
          This constructor will load the specified XML file and constructs the XMLNode tree.
XMLDataReader(java.lang.String urlString, java.lang.String ClassNameForXMLNode)
          This Constructor will load the specified XML file and constructs the XMLNode tree.
 
Method Summary
 java.util.Vector getRootChildNodes()
          Returns the vector of XMLNodes under the root node
 XMLNode getRootNode()
          This will retrieve the root element in the XML file
 void load(java.io.InputStream istream)
          Loads the specified XML from the specified InputStream and builds the XMLNode tree.
 void load(java.io.InputStream inputStream, int applicationType)
          Loads the specified XML from the specified InputStream and builds the XMLNode tree.
 void load(java.lang.String urlString)
          Loads the specified XML file and builds the XMLNode tree.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EJB_APPLICATION

public static final int EJB_APPLICATION

APPLICATION

public static final int APPLICATION

doValidate

boolean doValidate
Constructor Detail

XMLDataReader

public XMLDataReader(java.io.InputStream inputStream,
                     int applicationType)
The XMLDataReader which reads from the given InputStream.
Parameters:
inputStream - The input Stream from which the data has to be parsed.
applicationType - Specifies that the loaded xml file is from ordinary of EJB Application Type

XMLDataReader

public XMLDataReader(java.lang.String urlString)
This constructor will load the specified XML file and constructs the XMLNode tree.
Parameters:
urlString - (absolute/relative) path to the XML file

XMLDataReader

public XMLDataReader(java.lang.String urlString,
                     java.lang.String ClassNameForXMLNode)
This Constructor will load the specified XML file and constructs the XMLNode tree.
Parameters:
urlString - (absolute/relative) path to the XML file.
ClassNameForXMLNode - THe class name specified for the Xml node.

XMLDataReader

public XMLDataReader(java.lang.String fileName,
                     boolean isUrl)
              throws java.lang.Exception
This constructor will load the specified XML file and constructs the XMLNode tree.
Parameters:
urlString - (absolute/relative) path to the XML file.
isUrl - is a URL or a filename.
Throws:
java.lang.Exception - This Wraps all the excepitons thrown while processing this event.

XMLDataReader

public XMLDataReader(java.lang.String fileName,
                     boolean isUrl,
                     boolean doValidate)
              throws java.lang.Exception
This constructor will load the specified XML file and constructs the XMLNode tree.
Parameters:
urlString - (absolute/relative) path to the XML file.
isUrl - is a URL or a filename.
doValidate - to specify to validate the XML file with the specified DTD file declared in the DOCTYPE. By default doValidate is false.
Throws:
java.lang.Exception - This wraps all the Exceptions thrown during this event.

XMLDataReader

public XMLDataReader(java.lang.String fileName,
                     boolean isUrl,
                     boolean doValidate,
                     org.xml.sax.ErrorHandler errHandler)
              throws java.lang.Exception
This constructor will load the specified XML file and constructs the XMLNode tree.
Parameters:
urlString - (absolute/relative) path to the XML file.
isUrl - is a URL or a filename.
doValidate - to specify to validate the XML file with the specified DTD file declared in the DOCTYPE. By default doValidate is false.
errHandler - to specify the ErrorHandler that will handle errors that occur while parsing the XML file.
Throws:
java.lang.Exception - This wraps all the Exceptions thrown during this event.

XMLDataReader

public XMLDataReader(java.io.InputStream istream)
              throws java.lang.Exception
This constructor will load the specified XML from the InputStream and constructs the XMLNode tree.
Parameters:
istream - InputStream of the XML file.
Throws:
java.lang.Exception - This wraps all the Exceptions thrown while processing the event.

XMLDataReader

public XMLDataReader(java.io.InputStream istream,
                     java.lang.String ClassNameForXMLNode)
This Constructor will load the specified XML from the InputStream and and constructs the XMLNode tree.
Parameters:
istring - InputStream of XML file.
ClassNameForXMLNode - The Class name for the XML node.

XMLDataReader

public XMLDataReader()
When invoking this constructor, the user will need to follow it up by explicitly calling the load(String) method.
See Also:
load(String urlString), load(InputStream istream)
Method Detail

load

public void load(java.lang.String urlString)
Loads the specified XML file and builds the XMLNode tree.
Parameters:
urlString - (absolute/relative)path to the XML file

load

public void load(java.io.InputStream istream)
          throws java.lang.Exception
Loads the specified XML from the specified InputStream and builds the XMLNode tree.
Parameters:
urlString - (absolute/relative)path to the XML file

getRootNode

public XMLNode getRootNode()
This will retrieve the root element in the XML file
Returns:
XMLNode representing the root element

getRootChildNodes

public java.util.Vector getRootChildNodes()
Returns the vector of XMLNodes under the root node
Returns:
Vector of XMLNode objects representing the child elements of the root element in the XML file

load

public void load(java.io.InputStream inputStream,
                 int applicationType)
          throws java.lang.Exception
Loads the specified XML from the specified InputStream and builds the XMLNode tree.
Parameters:
inputStream - (absolute/relative)path to the XML file

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception