org.tigris.gef.persistence
Class SAXParserBase

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.tigris.gef.persistence.SAXParserBase
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public abstract class SAXParserBase
extends org.xml.sax.helpers.DefaultHandler

Author:
Jim Holt

Field Summary
protected static boolean DBG
          Switching this to true gives some extra logging messages.
 
Constructor Summary
SAXParserBase()
          The constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(java.lang.String uri, java.lang.String localname, java.lang.String name)
           
 java.lang.String getJarResource(java.lang.String cls)
           
 long getParseTime()
           
 boolean getStats()
           
protected abstract  void handleEndElement(XMLElement e)
          Implement in the concrete class to handle reaching the end tag of an element of interest.
protected abstract  void handleStartElement(XMLElement e)
          Implement in the concrete class to handle reaching the start tag of an element of interest.
 void ignoreElement(XMLElement e)
           
protected  boolean isElementOfInterest(java.lang.String name)
          Determine if an element of the given name is of interest to the parser.
 void notImplemented(XMLElement e)
           
 void parse(java.io.InputStream is)
           
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
 void setStats(boolean s)
           
 void startElement(java.lang.String uri, java.lang.String localname, java.lang.String name, org.xml.sax.Attributes atts)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBG

protected static final boolean DBG
Switching this to true gives some extra logging messages.

See Also:
Constant Field Values
Constructor Detail

SAXParserBase

public SAXParserBase()
The constructor.

Method Detail

setStats

public void setStats(boolean s)
Parameters:
s - true if statistics have to be shown

getStats

public boolean getStats()
Returns:
true if statistics have to be shown

getParseTime

public long getParseTime()
Returns:
the parsing time

parse

public void parse(java.io.InputStream is)
           throws org.xml.sax.SAXException
Parameters:
is - the inputstream of the project to read
Throws:
org.xml.sax.SAXException - when parsing xml

handleStartElement

protected abstract void handleStartElement(XMLElement e)
                                    throws org.xml.sax.SAXException
Implement in the concrete class to handle reaching the start tag of an element of interest.

Parameters:
e - the element.
Throws:
org.xml.sax.SAXException - on any error parsing the element.

handleEndElement

protected abstract void handleEndElement(XMLElement e)
                                  throws org.xml.sax.SAXException
Implement in the concrete class to handle reaching the end tag of an element of interest.

Parameters:
e - the element.
Throws:
org.xml.sax.SAXException - on any error parsing the element.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localname,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localname,
                       java.lang.String name)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

isElementOfInterest

protected boolean isElementOfInterest(java.lang.String name)
Determine if an element of the given name is of interest to the parser. The base implementation assumes always true.

Parameters:
name - the element name.
Returns:
true if the element name is of interest.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.characters(char[], int, int)

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

getJarResource

public java.lang.String getJarResource(java.lang.String cls)
Parameters:
cls - the class
Returns:
the jar

ignoreElement

public void ignoreElement(XMLElement e)
Parameters:
e - the element

notImplemented

public void notImplemented(XMLElement e)
Parameters:
e - the element