org.codehaus.dna.impl
Class SAXConfigurationHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.codehaus.dna.impl.SAXConfigurationHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

The SAXConfigurationHandler builds a Configuration tree from SAX events.

Version:
$Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
Author:
Peter Donald

Constructor Summary
SAXConfigurationHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive text data for current element.
 void clear()
          Reset internal state of handler in preapration for reuse.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          End an element and thus a Configuration object.
 void error(org.xml.sax.SAXParseException spe)
          Rethrow exception and dont attempt to do any error handling.
 void fatalError(org.xml.sax.SAXParseException spe)
          Rethrow exception and dont attempt to do any error handling.
 Configuration getConfiguration()
          Return the configuration created by handler.
protected  java.lang.String getLocationDescription()
          Utility method to derive current location of XML parser.
protected  java.lang.String processAttributeText(Configuration configuration, java.lang.String name, java.lang.String value)
          Users may subclass this method to process attribute prior to it being set.
protected  java.lang.String processValueText(Configuration configuration, java.lang.String value)
          Users may subclass this method to process content prior to it being set.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Let the XML parser specify locator for when events arrive at handler.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Start an element and thus a Configuration object.
 void warning(org.xml.sax.SAXParseException spe)
          Rethrow exception and dont attempt to do any error handling.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXConfigurationHandler

public SAXConfigurationHandler()
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Let the XML parser specify locator for when events arrive at handler.

Parameters:
locator - the locator

clear

public void clear()
Reset internal state of handler in preapration for reuse.


getConfiguration

public Configuration getConfiguration()
Return the configuration created by handler.

Returns:
the configuration created by handler.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Start an element and thus a Configuration object.

Parameters:
uri - the uri (ignored)
localName - the localName (ignored)
qName - the qualified name (used for name of configuration)
attributes - the attributes of XML element
Throws:
org.xml.sax.SAXException - if unable to parse element

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
End an element and thus a Configuration object. Will pop of configuration and value of object from stack. If the handler detects that element has both child elements and a text value then it will throw a SAXException.

Parameters:
uri - the uri (ignored)
localName - the localName (ignored)
qName - the qualified name (used for name of configuration)
Throws:
org.xml.sax.SAXException - if element had mixed content

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive text data for current element.

Parameters:
ch - the char array
start - the start index
length - the length of data
Throws:
org.xml.sax.SAXException - if unable ot parse data

warning

public void warning(org.xml.sax.SAXParseException spe)
             throws org.xml.sax.SAXException
Rethrow exception and dont attempt to do any error handling.

Parameters:
spe - the input exception
Throws:
org.xml.sax.SAXException - always thrown

error

public void error(org.xml.sax.SAXParseException spe)
           throws org.xml.sax.SAXException
Rethrow exception and dont attempt to do any error handling.

Parameters:
spe - the input exception
Throws:
org.xml.sax.SAXException - always thrown

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
                throws org.xml.sax.SAXException
Rethrow exception and dont attempt to do any error handling.

Parameters:
spe - the input exception
Throws:
org.xml.sax.SAXException - always thrown

getLocationDescription

protected final java.lang.String getLocationDescription()
Utility method to derive current location of XML parser. Attempts to build up a string containing systemID:lineNumber:columnNumber such as "file.xml:20:3" if parser supports all fields.

Returns:
the location description

processAttributeText

protected java.lang.String processAttributeText(Configuration configuration,
                                                java.lang.String name,
                                                java.lang.String value)
Users may subclass this method to process attribute prior to it being set.

Parameters:
configuration - the associated configuration
name - the attribute name
value - the attribute value
Returns:
the attribute value

processValueText

protected java.lang.String processValueText(Configuration configuration,
                                            java.lang.String value)
Users may subclass this method to process content prior to it being set.

Parameters:
configuration - the associated configuration
value - the value
Returns:
the value


Copyright © 2003-2004 Codehaus. All Rights Reserved.