Class StAXBuilder

  • All Implemented Interfaces:
    OMXMLParserWrapper
    Direct Known Subclasses:
    StAXOMBuilder

    public abstract class StAXBuilder
    extends Object
    implements OMXMLParserWrapper
    OM should be able to be built from any data source. And the model it builds may be a SOAP specific one or just an XML model. This class will give some common functionality of OM Building from StAX.
    • Field Detail

      • omfactory

        protected OMFactory omfactory
        Field omfactory
      • lastNode

        protected OMNode lastNode
        Field lastNode
      • done

        protected boolean done
        Field done
      • cache

        protected boolean cache
        Field cache
      • parserAccessed

        protected boolean parserAccessed
        Field parserAccessed
      • charEncoding

        protected String charEncoding
      • _isClosed

        protected boolean _isClosed
      • _releaseParserOnClose

        protected boolean _releaseParserOnClose
      • customBuilderForPayload

        protected CustomBuilder customBuilderForPayload
      • customBuilders

        protected Map customBuilders
      • maxDepthForCustomBuilders

        protected int maxDepthForCustomBuilders
      • dataHandlerReader

        protected DataHandlerReader dataHandlerReader
        Reference to the DataHandlerReader extension of the parser, or null if the parser doesn't support this extension.
      • elementLevel

        protected int elementLevel
        Element level is the depth of the element. The root element (i.e. envelope) is defined as 1.
      • parserException

        protected Exception parserException
        Stores exceptions thrown by the parser. Used to avoid accessing the parser again after is has thrown a parse exception.
    • Constructor Detail

      • StAXBuilder

        protected StAXBuilder​(OMFactory ombuilderFactory,
                              XMLStreamReader parser)
        Constructor StAXBuilder. This constructor is used if the parser is at the beginning (START_DOCUMENT).
        Parameters:
        ombuilderFactory -
        parser -
      • StAXBuilder

        protected StAXBuilder​(OMFactory ombuilderFactory,
                              XMLStreamReader parser,
                              String characterEncoding)
        Constructor StAXBuilder. This constructor is used if the parser is not at the START_DOCUMENT.
        Parameters:
        ombuilderFactory -
        parser -
        characterEncoding -
      • StAXBuilder

        protected StAXBuilder​(XMLStreamReader parser)
        Constructor StAXBuilder.
        Parameters:
        parser -
      • StAXBuilder

        protected StAXBuilder()
        Init() *must* be called after creating the builder using this constructor.
    • Method Detail

      • setOMBuilderFactory

        public void setOMBuilderFactory​(OMFactory ombuilderFactory)
        Method setOMBuilderFactory.
        Parameters:
        ombuilderFactory -
      • processNamespaceData

        protected abstract void processNamespaceData​(OMElement node)
        Method processNamespaceData.
        Parameters:
        node -
      • processAttributes

        protected void processAttributes​(OMElement node)
        Method processAttributes.
        Parameters:
        node -
      • createOMText

        protected OMNode createOMText​(int textType)
                               throws OMException
        Method createOMText.
        Returns:
        Returns OMNode.
        Throws:
        OMException
      • getNamespaceCount

        public int getNamespaceCount()
                              throws OMException
        Method getNamespaceCount.
        Returns:
        Returns int.
        Throws:
        OMException
      • getNamespacePrefix

        public String getNamespacePrefix​(int index)
                                  throws OMException
        Method getNamespacePrefix.
        Parameters:
        index -
        Returns:
        Returns String.
        Throws:
        OMException
      • getNamespaceUri

        public String getNamespaceUri​(int index)
                               throws OMException
        Method getNamespaceUri.
        Parameters:
        index -
        Returns:
        Returns String.
        Throws:
        OMException
      • setCache

        public void setCache​(boolean b)
        Method setCache.
        Specified by:
        setCache in interface OMXMLParserWrapper
        Parameters:
        b -
      • getAttributeCount

        public int getAttributeCount()
                              throws OMException
        Method getAttributeCount.
        Returns:
        Returns int.
        Throws:
        OMException
      • getAttributeNamespace

        public String getAttributeNamespace​(int arg)
                                     throws OMException
        Method getAttributeNamespace.
        Parameters:
        arg -
        Returns:
        Returns String.
        Throws:
        OMException
      • getAttributeName

        public String getAttributeName​(int arg)
                                throws OMException
        Method getAttributeName.
        Parameters:
        arg -
        Returns:
        Returns String.
        Throws:
        OMException
      • getAttributePrefix

        public String getAttributePrefix​(int arg)
                                  throws OMException
        Method getAttributePrefix.
        Parameters:
        arg -
        Returns:
        Returns String.
        Throws:
        OMException
      • isCompleted

        public boolean isCompleted()
        Method isCompleted.
        Specified by:
        isCompleted in interface OMXMLParserWrapper
        Returns:
        Returns boolean.
      • createOMElement

        protected abstract OMNode createOMElement()
                                           throws OMException
        This method is called with the XMLStreamConstants.START_ELEMENT event.
        Returns:
        Returns OMNode.
        Throws:
        OMException
      • next

        public abstract int next()
                          throws OMException
        Forwards the parser one step further, if parser is not completed yet. If this is called after parser is done, then throw an OMException. If the cache is set to false, then returns the event, *without* building the OM tree. If the cache is set to true, then handles all the events within this, and builds the object structure appropriately and returns the event.
        Specified by:
        next in interface OMXMLParserWrapper
        Returns:
        Returns int.
        Throws:
        OMException
      • registerCustomBuilder

        public CustomBuilder registerCustomBuilder​(QName qName,
                                                   int maxDepth,
                                                   CustomBuilder customBuilder)
        Register a CustomBuilder associated with the indicated QName. The CustomBuilder will be used when an element of that qname is encountered.
        Parameters:
        qName -
        maxDepth - indicate the maximum depth that this qname will be found. (root = 0)
        customBuilder -
        Returns:
        replaced CustomBuilder or null
      • registerCustomBuilderForPayload

        public CustomBuilder registerCustomBuilderForPayload​(CustomBuilder customBuilder)
        Register a CustomBuilder for a payload. The payload is defined as the elements inside a SOAPBody or the document element of a REST message.
        Parameters:
        customBuilder -
        Returns:
        replaced CustomBuilder or null
      • getCustomBuilder

        protected CustomBuilder getCustomBuilder​(String namespace,
                                                 String localPart)
        Return CustomBuilder associated with the namespace/localPart
        Parameters:
        namespace -
        localPart -
        Returns:
        CustomBuilder or null
      • getCharsetEncoding

        public String getCharsetEncoding()
      • getLastNode

        public OMNode getLastNode()
      • 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
      • getReaderProperty

        public Object getReaderProperty​(String name)
                                 throws IllegalArgumentException
        Get the value of a feature/property from the underlying XMLStreamReader implementation without accessing the XMLStreamReader. https://issues.apache.org/jira/browse/WSCOMMONS-155
        Parameters:
        name -
        Returns:
        TODO
        Throws:
        IllegalArgumentException
      • getCharacterEncoding

        public String getCharacterEncoding()
        Returns the encoding style of the XML data
        Specified by:
        getCharacterEncoding in interface OMXMLParserWrapper
        Returns:
        the character encoding, defaults to "UTF-8"
      • isClosed

        public boolean isClosed()
        Returns:
        if parser is closed
      • releaseParserOnClose

        public void releaseParserOnClose​(boolean value)
        Indicate if the parser resource should be release when closed.
        Parameters:
        value - boolean