zeus.concepts.xmlobject
Class Parser

java.lang.Object
  extended byzeus.concepts.xmlobject.Parser
Direct Known Subclasses:
ContactsParser

public abstract class Parser
extends java.lang.Object

Basic implementation for XML parsers. Performs DOM based validating parsing, requiring only that the translateRoot(Document) method be implemented to take control of the parsing. Requires an underlying Xerces parser to be available.


Field Summary
protected  java.io.InputStream inputStream
          Input data stream.
protected  java.lang.Object root
          Root object of the XML data.
 
Constructor Summary
Parser()
          Default constructor.
Parser(java.io.File file)
          Construct instance, and use specified file as input source.
Parser(java.lang.String string)
          Construct instance, and use specified string as input source.
 
Method Summary
 java.io.InputStream getInputStream()
          Retrieve the input stream for the parser.
 java.lang.Object getRootObject()
          Retrieve the root object.
 void load()
          Read the input source and build the Java object structure.
 void refresh()
          Update the object hierarchy from the current input stream.
protected  boolean setFeature(java.lang.String feature, org.apache.xerces.parsers.DOMParser parser)
          Set a feature of the parser.
 void setInputStream(java.io.InputStream inputStream)
          Set the input source for the parser.
 void setRootObject(java.lang.Object root)
          Set the root of the object hierarchy.
protected  void setupParser(org.apache.xerces.parsers.DOMParser parser)
          Set the validation features of the underlying parser.
protected abstract  java.lang.Object translateRoot(org.w3c.dom.Document doc)
          Translate the root element of the document, then return it as a Java object.
 boolean write(java.io.File file)
          Write the current root object to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStream

protected java.io.InputStream inputStream
Input data stream.


root

protected java.lang.Object root
Root object of the XML data.

Constructor Detail

Parser

public Parser()
Default constructor.


Parser

public Parser(java.io.File file)
       throws java.io.FileNotFoundException
Construct instance, and use specified file as input source.


Parser

public Parser(java.lang.String string)
Construct instance, and use specified string as input source.

Method Detail

translateRoot

protected abstract java.lang.Object translateRoot(org.w3c.dom.Document doc)
Translate the root element of the document, then return it as a Java object.


load

public void load()
Read the input source and build the Java object structure. Places the result into the root object variable.


setupParser

protected void setupParser(org.apache.xerces.parsers.DOMParser parser)
Set the validation features of the underlying parser. Currently requires a Xerces parser.


setFeature

protected boolean setFeature(java.lang.String feature,
                             org.apache.xerces.parsers.DOMParser parser)
Set a feature of the parser.


setInputStream

public void setInputStream(java.io.InputStream inputStream)
Set the input source for the parser.


getInputStream

public java.io.InputStream getInputStream()
Retrieve the input stream for the parser.


setRootObject

public void setRootObject(java.lang.Object root)
Set the root of the object hierarchy.


getRootObject

public java.lang.Object getRootObject()
Retrieve the root object. If it is currently null, it will attempt to load an instance from the input stream.


refresh

public void refresh()
Update the object hierarchy from the current input stream.


write

public boolean write(java.io.File file)
Write the current root object to the specified file.



Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.