org.davesag.generica.util.xml
Class AbstractXmlParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.davesag.generica.util.xml.AbstractXmlParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XmlParser
Direct Known Subclasses:
FaqXmlParser, LinkXmlParser, MediaTypeXmlParser, MediaXmlParser, MerchantXmlParser, SiteCopyXmlParser

public abstract class AbstractXmlParser
extends DefaultHandler
implements XmlParser

The AbstractXmlParser is an abstract root class for the other XMLParsers used in Generica.

Since:
Generica 1.0
Version:
CVS Revision $Id: AbstractXmlParser.java,v 1.10 2004/03/30 10:13:00 norm Exp $
Author:
Dave Sag http://www.davesag.com

Nested Class Summary
 
Nested classes inherited from class org.davesag.generica.util.xml.XmlParser
XmlParser.Factory
 
Field Summary
protected  StringBuffer theContent
          the text buffer of text between the start and end tags
protected  Object theCurrentItem
          the current item being worked on
protected  List theList
          the list of objects
protected  org.apache.xerces.parsers.SAXParser theParser
          the sax parser
 
Constructor Summary
protected AbstractXmlParser()
          default constructor
 
Method Summary
protected  void add(Object o)
          add to the list of parsed objects.
 void characters(char[] text, int start, int length)
          This method is called when CDATA elements are found.
protected  String getBuffer()
          get the buffer as a trimmed string.
protected  Object getCurrentItem()
          gets the current object
 List getList()
          gets the list of parsed objects.
protected  org.apache.xerces.parsers.SAXParser getParser()
          gets the current parser
 void parse(InputSource xml)
          parses the input source provided.
 void parse(String xmlfile)
          parses the file name provided.
 void parseString(String s)
          parses the string provided.
protected  void resetBuffer()
          resets the buffer
protected  void setCurrentItem(Object o)
          sets the current object
 void setParser(org.apache.xerces.parsers.SAXParser parser)
          set the parser to get calls from
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theParser

protected org.apache.xerces.parsers.SAXParser theParser
the sax parser


theList

protected List theList
the list of objects


theContent

protected StringBuffer theContent
the text buffer of text between the start and end tags


theCurrentItem

protected Object theCurrentItem
the current item being worked on

Constructor Detail

AbstractXmlParser

protected AbstractXmlParser()
default constructor

Method Detail

setParser

public void setParser(org.apache.xerces.parsers.SAXParser parser)
set the parser to get calls from

Specified by:
setParser in interface XmlParser
Parameters:
parser - the parser

getParser

protected org.apache.xerces.parsers.SAXParser getParser()
gets the current parser

Returns:
the current parser.

getList

public List getList()
gets the list of parsed objects.

Specified by:
getList in interface XmlParser
Returns:
The list of parsed objects.

add

protected void add(Object o)
add to the list of parsed objects. makes a clone of the object.

Parameters:
o - The object to clone and add to the list.

setCurrentItem

protected void setCurrentItem(Object o)
sets the current object

Parameters:
o - The curren object.

getCurrentItem

protected Object getCurrentItem()
gets the current object

Returns:
The curren object.

resetBuffer

protected void resetBuffer()
resets the buffer


getBuffer

protected String getBuffer()
get the buffer as a trimmed string.

Returns:
trimmed string version of internal buffer

parseString

public void parseString(String s)
parses the string provided.

Specified by:
parseString in interface XmlParser
Parameters:
s - The string to parse

parse

public void parse(InputSource xml)
parses the input source provided.

Specified by:
parse in interface XmlParser
Parameters:
xml - the input source to parse

parse

public void parse(String xmlfile)
parses the file name provided.

Specified by:
parse in interface XmlParser
Parameters:
xmlfile - the name of the file to parse

characters

public void characters(char[] text,
                       int start,
                       int length)
This method is called when CDATA elements are found. It trims and adds the chars to the internal buffer.

Specified by:
characters in interface ContentHandler
Parameters:
text - The array of chars
start - The start count
length - The length.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.