org.sadun.util.xml
Class SimplePathMapCreatorHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.sadun.util.xml.SimplePathMapCreatorHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, PathMap

public class SimplePathMapCreatorHandler
extends org.xml.sax.helpers.DefaultHandler
implements PathMap

This SAX handler can be used to create a map of simple paths to node values of an XML document.

After parsing, the method getValue(path) returns the textual value of the note indicated by the path. Paths are in the form

  /tag1/tag2/...
  /tag1/tag2/@attribute
 

Version:
1.0
Author:
Cristiano Sadun

Constructor Summary
SimplePathMapCreatorHandler()
          Construct an instance that trims whitespace in values.
SimplePathMapCreatorHandler(boolean trimWhiteSpace)
          Construct an instance that trims whitespace in values depending on the value of the given parameter.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 java.lang.String getValue(java.lang.String path)
          Return the textual value of the note indicated by the path.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atts)
           
 
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

SimplePathMapCreatorHandler

public SimplePathMapCreatorHandler(boolean trimWhiteSpace)
Construct an instance that trims whitespace in values depending on the value of the given parameter.

Parameters:
trimWhiteSpace - if true, the instance will trim whitespace.

SimplePathMapCreatorHandler

public SimplePathMapCreatorHandler()
Construct an instance that trims whitespace in values.

Method Detail

characters

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

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

getValue

public java.lang.String getValue(java.lang.String path)
Description copied from interface: PathMap
Return the textual value of the note indicated by the path.

Specified by:
getValue in interface PathMap
Parameters:
path - the path, in a given path language
Returns:
the textual value of the note indicated by the path.