org.apache.axiom.om.impl.builder
Class SAXOMBuilder

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.axiom.om.impl.builder.SAXOMBuilder
All Implemented Interfaces:
OMXMLParserWrapper, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler

public class SAXOMBuilder
extends DefaultHandler
implements LexicalHandler, DeclHandler, OMXMLParserWrapper


Constructor Summary
SAXOMBuilder()
          Deprecated. Instead of creating an instance of this class directly, create a SAXSource and use OMXMLBuilderFactory.createOMBuilder(SAXSource, boolean).
SAXOMBuilder(OMFactory factory)
          Deprecated. Instead of creating an instance of this class directly, create a SAXSource and use OMXMLBuilderFactory.createOMBuilder(OMFactory, SAXSource, boolean).
SAXOMBuilder(OMFactory factory, SAXSource source, boolean expandEntityReferences)
          For internal use only.
 
Method Summary
 void attributeDecl(String eName, String aName, String type, String mode, String value)
           
 void characterData(char[] ch, int start, int length, int nodeType)
           
 void characters(char[] ch, int start, int length)
           
 void close()
          Close this builder.
 void comment(char[] ch, int start, int length)
           
protected  OMElement createNextElement(String localName)
           
 void discard(OMElement el)
           
 void elementDecl(String name, String model)
           
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(String uri, String localName, String qName)
           
 void endEntity(String name)
           
 void endPrefixMapping(String prefix)
           
 void externalEntityDecl(String name, String publicId, String systemId)
           
 short getBuilderType()
          Returns the type of the builder.
 String getCharacterEncoding()
          Returns the encoding style of the XML data
 OMDocument getDocument()
          Get the document being built by this builder.
 OMElement getDocumentElement()
          Get the document element, i.e. the root element of the document.
 OMElement getDocumentElement(boolean discardDocument)
          Get the document element, optionally discarding the document.
 Object getParser()
          Allows to access the underlying parser.
 Object getRegisteredContentHandler()
          get the registered external content handler
 OMElement getRootElement()
          Get the root element of the Axiom tree built by this content handler.
 void ignorableWhitespace(char[] ch, int start, int length)
           
 void internalEntityDecl(String name, String value)
           
 boolean isCache()
           
 boolean isCompleted()
           
 int next()
          Proceed the parser one step and return the event value.
 void notationDecl(String name, String publicId, String systemId)
           
 void processingInstruction(String target, String data)
           
 void registerExternalContentHandler(Object obj)
          Registers an external content handler.
 void setCache(boolean b)
           
 void setDocumentLocator(Locator locator)
           
 void skippedEntity(String name)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
           
 void startEntity(String name)
           
 void startPrefixMapping(String prefix, String uri)
           
 void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, resolveEntity, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXOMBuilder

public SAXOMBuilder(OMFactory factory,
                    SAXSource source,
                    boolean expandEntityReferences)
For internal use only.

Parameters:
factory -
source -
expandEntityReferences -

SAXOMBuilder

public SAXOMBuilder(OMFactory factory)
Deprecated. Instead of creating an instance of this class directly, create a SAXSource and use OMXMLBuilderFactory.createOMBuilder(OMFactory, SAXSource, boolean).


SAXOMBuilder

public SAXOMBuilder()
Deprecated. Instead of creating an instance of this class directly, create a SAXSource and use OMXMLBuilderFactory.createOMBuilder(SAXSource, boolean).

Method Detail

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

elementDecl

public void elementDecl(String name,
                        String model)
                 throws SAXException
Specified by:
elementDecl in interface DeclHandler
Throws:
SAXException

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String mode,
                          String value)
                   throws SAXException
Specified by:
attributeDecl in interface DeclHandler
Throws:
SAXException

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
                        throws SAXException
Specified by:
externalEntityDecl in interface DeclHandler
Throws:
SAXException

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
                        throws SAXException
Specified by:
internalEntityDecl in interface DeclHandler
Throws:
SAXException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
                  throws SAXException
Specified by:
notationDecl in interface DTDHandler
Overrides:
notationDecl in class DefaultHandler
Throws:
SAXException

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
                        throws SAXException
Specified by:
unparsedEntityDecl in interface DTDHandler
Overrides:
unparsedEntityDecl in class DefaultHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

createNextElement

protected OMElement createNextElement(String localName)
                               throws OMException
Throws:
OMException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

characterData

public void characterData(char[] ch,
                          int start,
                          int length,
                          int nodeType)
                   throws SAXException
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class DefaultHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

getDocument

public OMDocument getDocument()
Description copied from interface: OMXMLParserWrapper
Get the document being built by this builder.

Specified by:
getDocument in interface OMXMLParserWrapper
Returns:
the OMDocument instance

getRootElement

public OMElement getRootElement()
Get the root element of the Axiom tree built by this content handler.

Returns:
the root element of the tree
Throws:
OMException - if the tree is not complete

next

public int next()
         throws OMException
Description copied from interface: OMXMLParserWrapper
Proceed the parser one step and return the event value.

Specified by:
next in interface OMXMLParserWrapper
Returns:
Returns int.
Throws:
OMException

discard

public void discard(OMElement el)
             throws OMException
Specified by:
discard in interface OMXMLParserWrapper
Throws:
OMException

setCache

public void setCache(boolean b)
              throws OMException
Specified by:
setCache in interface OMXMLParserWrapper
Throws:
OMException

isCache

public boolean isCache()
Specified by:
isCache in interface OMXMLParserWrapper
Returns:
true if caching

getParser

public Object getParser()
Description copied from interface: OMXMLParserWrapper
Allows to access the underlying parser. Since the parser depends on the underlying implementation, an Object is returned. However the implementations may have restrictions in letting access to the parser.

Specified by:
getParser in interface OMXMLParserWrapper
Returns:
Returns Object.

isCompleted

public boolean isCompleted()
Specified by:
isCompleted in interface OMXMLParserWrapper
Returns:
Returns the complete status.

getDocumentElement

public OMElement getDocumentElement()
Description copied from interface: OMXMLParserWrapper
Get the document element, i.e. the root element of the document. Using this method is equivalent to using OMDocument.getOMDocumentElement() on the document returned by OMXMLParserWrapper.getDocument().

Note that this method will never return null (except in the very special case where the document has been requested before and the document element has been removed explicitly): if the document being parsed has no document element, then this will result in a parser error, i.e. an OMException will be thrown.

Specified by:
getDocumentElement in interface OMXMLParserWrapper
Returns:
the document element

getDocumentElement

public OMElement getDocumentElement(boolean discardDocument)
Description copied from interface: OMXMLParserWrapper
Get the document element, optionally discarding the document. The return value of this method is the same as OMXMLParserWrapper.getDocumentElement(). However, if the discardDocument parameter is set to true, then the document element is removed from the document and the document itself is discarded. In contrast to using OMNode.detach() this will not build the element. The implementation also ensures that the element is not built when it is added to another OM tree. This makes it possible to add the content of a document to an existing OM tree while preserving the deferred parsing feature. It is even possible to create an OM tree where different subtrees are associated with different builder instances.

Specified by:
getDocumentElement in interface OMXMLParserWrapper
Parameters:
discardDocument - specifies whether the document should be discarded
Returns:
the document element

getBuilderType

public short getBuilderType()
Description copied from interface: OMXMLParserWrapper
Returns the type of the builder. Can be either OMConstants.PUSH_TYPE_BUILDER or OMConstants.PULL_TYPE_BUILDER.

Specified by:
getBuilderType in interface OMXMLParserWrapper
Returns:
Returns short.

registerExternalContentHandler

public void registerExternalContentHandler(Object obj)
Description copied from interface: OMXMLParserWrapper
Registers an external content handler. Especially useful for push type builders. Throws an unsupportedOperationException if such handler registration is not supported.

Specified by:
registerExternalContentHandler in interface OMXMLParserWrapper

getRegisteredContentHandler

public Object getRegisteredContentHandler()
Description copied from interface: OMXMLParserWrapper
get the registered external content handler

Specified by:
getRegisteredContentHandler in interface OMXMLParserWrapper
Returns:
Returns Object.

getCharacterEncoding

public String getCharacterEncoding()
Description copied from interface: OMXMLParserWrapper
Returns the encoding style of the XML data

Specified by:
getCharacterEncoding in interface OMXMLParserWrapper
Returns:
the character encoding, defaults to "UTF-8"

close

public void close()
Description copied from interface: OMXMLParserWrapper
Close this builder. This method frees the resources associated with this builder. In particular, it releases the resources held by the underlying parser. This method does not close the underlying input source.

Specified by:
close in interface OMXMLParserWrapper


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.