net.sundog.hoople
Class BaseParser

java.lang.Object
  extended bynet.sundog.hoople.BaseParser
Direct Known Subclasses:
BaseXMLGeneratingParser, ExtensionParser, GoogleSiteMapParser

public abstract class BaseParser
extends java.lang.Object

The base class that all Hoople Parsers must extend from. It can be used on both a compile-time ant setting or at run time. It works like a SAXParser, but with less configuration needed.

As URLConfigParser is parsing a file, keeps track of which BaseParsers is interested in a particular section of the XML file. So, for example, the StrutsParser will only have methods called on it in the <struts> section.

When the URLConfigParser is parsing a section of the XML that a BaseParser is interested in, it will call startElement and endElement as it gets to the beginning and end of each element.


Constructor Summary
protected BaseParser(java.lang.String configSectionParentTagName)
          Pass the name of the tag that determines when this parser should start having startElement and endElement methods called.
 
Method Summary
protected  java.lang.String convertToAbsolutePath(java.io.File relativeTo, java.lang.String path)
          Return the absolute url of the given path.
abstract  void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String elementText, java.io.File file, java.io.File documentRoot)
          Override this method with things to do when the URLConfigParser finds the end of an element and isActive() returns true.
 javax.xml.parsers.DocumentBuilder getDocumentBuilder()
           
 URLConfigParser getUrlConfigurationParser()
           
 boolean isActive()
           
protected  void setActive(boolean active)
           
 void setActive(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Called at the start and end of all tags to let this parser opt-in or out of having its startElelment and endElement methods called.
 void setDocumentBuilder(javax.xml.parsers.DocumentBuilder documentBuilder)
           
 void setUrlConfigurationParser(URLConfigParser UrlConfigParser)
           
abstract  void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes, java.io.File urlConfigFile, java.io.File documentRoot)
          Override this method with things to do when the URLConfigParser finds the start of an element and isActive() returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseParser

protected BaseParser(java.lang.String configSectionParentTagName)
Pass the name of the tag that determines when this parser should start having startElement and endElement methods called.

Method Detail

getUrlConfigurationParser

public URLConfigParser getUrlConfigurationParser()

setUrlConfigurationParser

public void setUrlConfigurationParser(URLConfigParser UrlConfigParser)

getDocumentBuilder

public javax.xml.parsers.DocumentBuilder getDocumentBuilder()

setDocumentBuilder

public void setDocumentBuilder(javax.xml.parsers.DocumentBuilder documentBuilder)

startElement

public abstract void startElement(java.lang.String uri,
                                  java.lang.String localName,
                                  java.lang.String qName,
                                  org.xml.sax.Attributes attributes,
                                  java.io.File urlConfigFile,
                                  java.io.File documentRoot)
                           throws org.xml.sax.SAXException,
                                  java.io.IOException
Override this method with things to do when the URLConfigParser finds the start of an element and isActive() returns true.

Throws:
org.xml.sax.SAXException
java.io.IOException

endElement

public abstract void endElement(java.lang.String uri,
                                java.lang.String localName,
                                java.lang.String qName,
                                java.lang.String elementText,
                                java.io.File file,
                                java.io.File documentRoot)
                         throws org.xml.sax.SAXException
Override this method with things to do when the URLConfigParser finds the end of an element and isActive() returns true.

Throws:
org.xml.sax.SAXException

convertToAbsolutePath

protected java.lang.String convertToAbsolutePath(java.io.File relativeTo,
                                                 java.lang.String path)
                                          throws java.io.IOException
Return the absolute url of the given path. If the given path is a relative path, the absolute path will be relative to the relativeTo file.

Throws:
java.io.IOException

isActive

public boolean isActive()

setActive

protected void setActive(boolean active)

setActive

public void setActive(java.lang.String uri,
                      java.lang.String localName,
                      java.lang.String qName,
                      org.xml.sax.Attributes attributes)
               throws org.xml.sax.SAXException
Called at the start and end of all tags to let this parser opt-in or out of having its startElelment and endElement methods called.

Throws:
org.xml.sax.SAXException


Copyright © 2005 Sundog. All Rights Reserved.