com.objectwave.templateMerge
Class XMLTemplateRead

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.objectwave.templateMerge.XMLTemplateRead
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XMLTemplateRead
extends org.xml.sax.helpers.DefaultHandler

This class is used to read the XML file and translate it into KnownTemplates

Version:
$Id: XMLTemplateRead.java,v 2.3 2002/08/14 17:58:52 dave_hoag Exp $
Author:
Zhou Cai

Nested Class Summary
static class XMLTemplateRead.Test
          Unit Test
 
Constructor Summary
XMLTemplateRead()
          Constructor with no parameters.
XMLTemplateRead(java.io.Reader input)
          Constructor
XMLTemplateRead(java.lang.String uri)
          Constructor
 
Method Summary
 void characters(char[] ch, int start, int length)
          This method will read the characters in an XML document.
 void endElement(java.lang.String uri, java.lang.String local, java.lang.String raw)
          This method will parse the collection in an XML document.
protected  java.util.Vector getBody(java.lang.String body)
          read a string line by line and write them into a vector
 KnownTemplates getTemplates()
          Get the KnowTemplates which has all information in the XML file
protected  InformationToken[] getTokens(java.lang.String token)
          read a String line by line and get the token array according the token name
protected  void initialize()
           
protected  void parse(org.xml.sax.InputSource uri)
          Parse the XML
protected  void parse(java.lang.String uri)
          Parse the XML
protected  void setPostTemplate()
          set the post part for the current template
protected  void setPreTemplate()
          set the pre part for the current template
protected  void setSubTemplate()
          set the sub templates for the current template
 void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs)
          This method will parse a single element in an XML document.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTemplateRead

public XMLTemplateRead()
Constructor with no parameters.


XMLTemplateRead

public XMLTemplateRead(java.lang.String uri)
                throws ConfigurationException
Constructor

Parameters:
uri - String the XML file name
Throws:
ConfigurationException

XMLTemplateRead

public XMLTemplateRead(java.io.Reader input)
                throws ConfigurationException
Constructor

Parameters:
input - Reader
Throws:
ConfigurationException
Method Detail

setPreTemplate

protected void setPreTemplate()
set the pre part for the current template


setPostTemplate

protected void setPostTemplate()
set the post part for the current template


setSubTemplate

protected void setSubTemplate()
set the sub templates for the current template


getTemplates

public KnownTemplates getTemplates()
Get the KnowTemplates which has all information in the XML file

Returns:
KnownTemplates

getTokens

protected InformationToken[] getTokens(java.lang.String token)
                                throws java.io.IOException
read a String line by line and get the token array according the token name

Parameters:
token - String the string to be read
Returns:
InformationToken[] an array composed of tokens
Throws:
java.io.IOException

getBody

protected java.util.Vector getBody(java.lang.String body)
                            throws java.io.IOException
read a string line by line and write them into a vector

Parameters:
body - String the string to be read
Returns:
Vector
Throws:
java.io.IOException

initialize

protected void initialize()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String local,
                         java.lang.String raw,
                         org.xml.sax.Attributes attrs)
This method will parse a single element in an XML document. It is called automatically by the XML Parser.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - String The Namespace URI
local - String The local name (without prefix)
raw - String The raw XML 1.0 name (with prefix)
attrs - Attributes The attributes attached to the element.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String local,
                       java.lang.String raw)
This method will parse the collection in an XML document. It is called automatically by the XML Parser.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - String The Namespace URI
local - String The local name (without prefix)
raw - String The raw XML 1.0 name (with prefix)

characters

public void characters(char[] ch,
                       int start,
                       int length)
This method will read the characters in an XML document. It is called automatically by the XML Parser.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - char array The characters from the XML document.
start - integer The start position in the array.
length - integer The number of characters to read from the array

parse

protected void parse(java.lang.String uri)
              throws ConfigurationException
Parse the XML

Parameters:
uri - The XML file name
Throws:
ConfigurationException - If any error happen in the XML file processing

parse

protected void parse(org.xml.sax.InputSource uri)
              throws ConfigurationException
Parse the XML

Parameters:
uri - The input source of the XML data.
Throws:
ConfigurationException - If any error happen in the XML file processing