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

java.lang.Object
  extended by org.apache.axiom.om.impl.builder.SAXOMXMLParserWrapper
All Implemented Interfaces:
OMXMLParserWrapper

public class SAXOMXMLParserWrapper
extends Object
implements OMXMLParserWrapper

OMXMLParserWrapper implementation for SAX parsers. By "SAX parser" we mean anything that is able to write a sequence of events to a SAX ContentHandler.

Note: This is a very naive implementation. Other implementations of the Axiom API may provide smarter implementations. For example, in theory it should be possible to defer the invocation of the parser until the OMElement object returned by getDocumentElement() is accessed.


Constructor Summary
SAXOMXMLParserWrapper(OMFactory factory, SAXSource source)
           
 
Method Summary
 void close()
          Close this builder.
 void discard(OMElement el)
          Discards the current element.
 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
 boolean isCache()
           
 boolean isCompleted()
           
 int next()
          Proceed the parser one step and return the event value.
 void registerExternalContentHandler(Object obj)
          Registers an external content handler.
 void setCache(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXOMXMLParserWrapper

public SAXOMXMLParserWrapper(OMFactory factory,
                             SAXSource source)
Method Detail

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

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().

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

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

discard

public void discard(OMElement el)
             throws OMException
Description copied from interface: OMXMLParserWrapper
Discards the current element. This will remove the given element and its descendants.

Specified by:
discard in interface OMXMLParserWrapper
Throws:
OMException

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.

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"

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.

getRegisteredContentHandler

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

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

isCache

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

isCompleted

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

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

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

setCache

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


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