com.openharbor.beck.sax
Class DefaultSAXContentHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.openharbor.beck.sax.DefaultSAXContentHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, MapFromXML.Aware, SAXContentHandler, XMLContext
Direct Known Subclasses:
OHXContentHandler

public class DefaultSAXContentHandler
extends org.xml.sax.helpers.DefaultHandler
implements SAXContentHandler, XMLContext, MapFromXML.Aware

Handles XML data from a SAX2 event stream.


Field Summary
protected  org.apache.commons.logging.Log log
           
protected  MapFromXML mapper
           
protected  org.xml.sax.helpers.NamespaceSupport namespaces
           
protected  boolean needNamespaceContext
           
 
Constructor Summary
DefaultSAXContentHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Add text content to current object.
protected  void clear()
          Release all resources and subsequently behave as though newly returned from MapFromXML.newContentHandler.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Process end of element.
 java.lang.String getBaseURI()
          The base URI to be used when resolving an external reference or reporting an error.
 org.xml.sax.EntityResolver getEntityResolver()
          The current algorithm for resolving external references.
 MapFromXML getMapFromXML()
           
protected  XMLReceiver getReceiver()
           
 java.lang.Object getResult()
           
static java.util.Map newAttributeMap(org.xml.sax.Attributes attrs)
           
 java.lang.Object removeResult()
          Get the Java object that was copied from the XML document and also release all resources and subsequently behave as though newly returned from MapFromXML.newContentHandler.
 XMLName resolveNamespace(java.lang.String qname, boolean isAttribute)
          Resolve an XML name to its namespace URI and local part.
 void setBaseURI(java.lang.String uri)
           
 void setEntityResolver(org.xml.sax.EntityResolver e)
           
 void setMapFromXML(MapFromXML mapper)
           
protected  void setReceiver(XMLReceiver receiver)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String raw, org.xml.sax.Attributes attrs)
          Start element.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
protected  void throwSAXException(java.lang.String message, java.lang.Exception e)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity
 

Field Detail

log

protected final org.apache.commons.logging.Log log

mapper

protected MapFromXML mapper

namespaces

protected org.xml.sax.helpers.NamespaceSupport namespaces

needNamespaceContext

protected boolean needNamespaceContext
Constructor Detail

DefaultSAXContentHandler

public DefaultSAXContentHandler()
Method Detail

setMapFromXML

public void setMapFromXML(MapFromXML mapper)
Specified by:
setMapFromXML in interface MapFromXML.Aware

getMapFromXML

public MapFromXML getMapFromXML()
Specified by:
getMapFromXML in interface MapFromXML.Aware

setReceiver

protected void setReceiver(XMLReceiver receiver)

getReceiver

protected XMLReceiver getReceiver()

setBaseURI

public void setBaseURI(java.lang.String uri)
Specified by:
setBaseURI in interface SAXContentHandler

getBaseURI

public java.lang.String getBaseURI()
Description copied from interface: XMLContext
The base URI to be used when resolving an external reference or reporting an error.

Specified by:
getBaseURI in interface XMLContext

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver e)
Specified by:
setEntityResolver in interface SAXContentHandler

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Description copied from interface: XMLContext
The current algorithm for resolving external references.

Specified by:
getEntityResolver in interface XMLContext
Returns:
the object that resolves external references, or null to indicate that the default resolution algorithm should be used.

clear

protected void clear()
Release all resources and subsequently behave as though newly returned from MapFromXML.newContentHandler. This object remains bound to a MapFromXML, but all state pertaining to the current XML document is cleared.


resolveNamespace

public XMLName resolveNamespace(java.lang.String qname,
                                boolean isAttribute)
                         throws UnknownNamespaceException
Description copied from interface: XMLContext
Resolve an XML name to its namespace URI and local part.

Specified by:
resolveNamespace in interface XMLContext
Parameters:
qname - an XML local name or qualified name (of the form prefix:localPart).
isAttribute - whether this is the name of an XML attribute. The resolution algorithm for an attribute name is slightly different than for an element name.
Returns:
the namespace URI (if any) and local part.
Throws:
UnknownNamespaceException - the qname's prefix has not been defined (by an xmlns:prefix declaration).

getResult

public java.lang.Object getResult()
Specified by:
getResult in interface SAXContentHandler
Returns:
the Java object that was copied from the XML document.

removeResult

public java.lang.Object removeResult()
Description copied from interface: SAXContentHandler
Get the Java object that was copied from the XML document and also release all resources and subsequently behave as though newly returned from MapFromXML.newContentHandler. This object remains bound to a MapFromXML, but all state pertaining to the current XML document is cleared.

Specified by:
removeResult in interface SAXContentHandler

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startPrefixMapping

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

newAttributeMap

public static java.util.Map newAttributeMap(org.xml.sax.Attributes attrs)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String raw,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Start element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Add text content to current object.

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
Process end of element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

throwSAXException

protected void throwSAXException(java.lang.String message,
                                 java.lang.Exception e)
                          throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException