org.apache.synapse.commons.staxon.core.base

## Class AbstractXMLStreamReader<T>

- java.lang.Object
- - org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader<T>

- All Implemented Interfaces:
    XMLStreamConstants, XMLStreamReader
  Direct Known Subclasses:
    JsonXMLStreamReader

      public abstract class AbstractXMLStreamReader<T>
      extends Object
      implements XMLStreamReader

  Abstract XML stream reader.

- - ### Field Summary

    - ### Fields inherited from interface javax.xml.stream.XMLStreamConstants

      `ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractXMLStreamReader(T rootInfo)` Create new reader instance.
    `AbstractXMLStreamReader(T rootInfo, Location locationProvider)` Create new reader instance.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected abstract boolean` | `consume()` Main method to be implemented by subclasses.
    `int` | `getAttributeCount()`
    `String` | `getAttributeLocalName(int index)`
    `QName` | `getAttributeName(int index)`
    `String` | `getAttributeNamespace(int index)`
    `String` | `getAttributePrefix(int index)`
    `String` | `getAttributeType(int index)`
    `String` | `getAttributeValue(int index)`
    `String` | `getAttributeValue(String namespaceURI, String localName)`
    `String` | `getCharacterEncodingScheme()`
    `String` | `getElementText()`
    `String` | `getEncoding()`
    `protected Object` | `getEventData()`
    `protected String` | `getEventName()`
    `int` | `getEventType()`
    `String` | `getLocalName()`
    `Location` | `getLocation()`
    `QName` | `getName()`
    `NamespaceContext` | `getNamespaceContext()`
    `int` | `getNamespaceCount()`
    `String` | `getNamespacePrefix(int index)`
    `String` | `getNamespaceURI()`
    `String` | `getNamespaceURI(int index)`
    `String` | `getNamespaceURI(String prefix)`
    `String` | `getPIData()`
    `String` | `getPITarget()`
    `String` | `getPrefix()`
    `Object` | `getProperty(String name)`
    `protected XMLStreamReaderScope<T>` | `getScope()`
    `String` | `getText()`
    `char[]` | `getTextCharacters()`
    `int` | `getTextCharacters(int sourceStart, char[] target, int targetStart, int length)`
    `int` | `getTextLength()`
    `int` | `getTextStart()`
    `String` | `getVersion()`
    `boolean` | `hasName()`
    `boolean` | `hasNext()`
    `boolean` | `hasText()`
    `protected void` | `initialize()` Consume initial event.
    `boolean` | `isAttributeSpecified(int index)`
    `boolean` | `isCharacters()`
    `boolean` | `isEndElement()`
    `boolean` | `isStandalone()`
    `protected boolean` | `isStartDocumentRead()`
    `boolean` | `isStartElement()`
    `boolean` | `isWhiteSpace()`
    `int` | `next()`
    `int` | `nextTag()`
    `protected void` | `readAttr(String prefix, String localName, String namespaceURI, String value)` Read attribute.
    `protected void` | `readData(String text, Object data, int type)` Read characters/comment/dtd/entity data.
    `protected void` | `readEndDocument()` Read end document.
    `protected void` | `readEndElementTag()` Read end element.
    `protected void` | `readNsDecl(String prefix, String namespaceURI)` Read namespace declaration.
    `protected void` | `readPI(String target, String data)` Read processing instruction.
    `protected void` | `readStartDocument(String version, String encodingScheme, Boolean standalone)` Read start document
    `protected void` | `readStartElementTag(String prefix, String localName, String namespaceURI, T scopeInfo)` Read start element.
    `void` | `require(int eventType, String namespaceURI, String localName)`
    `boolean` | `standaloneSet()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractXMLStreamReader

          public AbstractXMLStreamReader(T rootInfo)

      Create new reader instance.
      Parameters:
        `rootInfo` - root scope information

    - #### AbstractXMLStreamReader

          public AbstractXMLStreamReader(T rootInfo,
                                         Location locationProvider)

      Create new reader instance.
      Parameters:
        `rootInfo` - root scope information

  - ### Method Detail

    - #### getScope

          protected XMLStreamReaderScope<T> getScope()

      Returns:
        current scope

    - #### isStartDocumentRead

          protected boolean isStartDocumentRead()

      Returns:
        `true` if `START_DOCUMENT` event has been read

    - #### initialize

          protected void initialize()
                             throws XMLStreamException

      Consume initial event. This method must be called by subclasses prior to any use of an instance (typically in constructor).
      Throws:
        `XMLStreamException`

    - #### consume

          protected abstract boolean consume()
                                      throws XMLStreamException,
                                             IOException

      Main method to be implemented by subclasses. This method is called by the reader when the event queue runs dry. Consume some events and delegate to the various `readXXX()` methods. When encountering an element start event, all attributes and namespace delarations must be consumed too, otherwise these won't be available during start element.
      Returns:
        `true` if there's more to read
      Throws:
        `XMLStreamException`
        `IOException`

    - #### readStartDocument

          protected void readStartDocument(String version,
                                           String encodingScheme,
                                           Boolean standalone)
                                    throws XMLStreamException

      Read start document
      Parameters:
        `version` - XML version
        `encodingScheme` - encoding scheme (may be `null`)
        `standalone` - standalone flag (may be `null`)
      Throws:
        `XMLStreamException`

    - #### readStartElementTag

          protected void readStartElementTag(String prefix,
                                             String localName,
                                             String namespaceURI,
                                             T scopeInfo)
                                      throws XMLStreamException

      Read start element. A new scope is created and made the current scope. The provided `scopeInfo` is stored in the new scope and will be available via `getScope().getInfo()`.
      Parameters:
        `prefix` - element prefix (use `null` if unknown)
        `localName` - local name
        `namespaceURI` - (use `null` if unknown)
        `scopeInfo` - new scope info
      Throws:
        `XMLStreamException`

    - #### readAttr

          protected void readAttr(String prefix,
                                  String localName,
                                  String namespaceURI,
                                  String value)
                           throws XMLStreamException

      Read attribute.
      Parameters:
        `prefix` - attribute prefix (use `null` if unknown)
        `localName` - local name
        `namespaceURI` - (use `null` if unknown)
        `value` - attribute value
      Throws:
        `XMLStreamException`

    - #### readNsDecl

          protected void readNsDecl(String prefix,
                                    String namespaceURI)
                             throws XMLStreamException

      Read namespace declaration.
      Parameters:
        `prefix` - namespace prefix (must not be `null`)
        `namespaceURI` - namespace URI (must not be `null`)
      Throws:
        `XMLStreamException`

    - #### readData

          protected void readData(String text,
                                  Object data,
                                  int type)
                           throws XMLStreamException

      Read characters/comment/dtd/entity data.
      Parameters:
        `text` - text
        `data` - additional data exposed by `getEventData()` (e.g. type conversion)
        `type` - one of `CHARACTERS, COMMENT, CDATA, DTD, ENTITY_REFERENCE, SPACE`
      Throws:
        `XMLStreamException`

    - #### readPI

          protected void readPI(String target,
                                String data)
                         throws XMLStreamException

      Read processing instruction.
      Parameters:
        `target` - PI target
        `data` - PI data (may be `null`)
      Throws:
        `XMLStreamException`

    - #### readEndElementTag

          protected void readEndElementTag()
                                    throws XMLStreamException

      Read end element. This will pop the current scope and make its parent the new current scope.
      Throws:
        `XMLStreamException`

    - #### readEndDocument

          protected void readEndDocument()
                                  throws XMLStreamException

      Read end document.
      Throws:
        `XMLStreamException`

    - #### require

          public void require(int eventType,
                              String namespaceURI,
                              String localName)
                       throws XMLStreamException

      Specified by:
        `require` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### getElementText

          public String getElementText()
                                throws XMLStreamException

      Specified by:
        `getElementText` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### hasNext

          public boolean hasNext()
                          throws XMLStreamException

      Specified by:
        `hasNext` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### next

          public int next()
                   throws XMLStreamException

      Specified by:
        `next` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### nextTag

          public int nextTag()
                      throws XMLStreamException

      Specified by:
        `nextTag` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### close

          public void close()
                     throws XMLStreamException

      Specified by:
        `close` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### isStartElement

          public boolean isStartElement()

      Specified by:
        `isStartElement` in interface `XMLStreamReader`

    - #### isEndElement

          public boolean isEndElement()

      Specified by:
        `isEndElement` in interface `XMLStreamReader`

    - #### isCharacters

          public boolean isCharacters()

      Specified by:
        `isCharacters` in interface `XMLStreamReader`

    - #### isWhiteSpace

          public boolean isWhiteSpace()

      Specified by:
        `isWhiteSpace` in interface `XMLStreamReader`

    - #### getAttributeCount

          public int getAttributeCount()

      Specified by:
        `getAttributeCount` in interface `XMLStreamReader`

    - #### getAttributeName

          public QName getAttributeName(int index)

      Specified by:
        `getAttributeName` in interface `XMLStreamReader`

    - #### getAttributeLocalName

          public String getAttributeLocalName(int index)

      Specified by:
        `getAttributeLocalName` in interface `XMLStreamReader`

    - #### getAttributeValue

          public String getAttributeValue(int index)

      Specified by:
        `getAttributeValue` in interface `XMLStreamReader`

    - #### getAttributePrefix

          public String getAttributePrefix(int index)

      Specified by:
        `getAttributePrefix` in interface `XMLStreamReader`

    - #### getAttributeNamespace

          public String getAttributeNamespace(int index)

      Specified by:
        `getAttributeNamespace` in interface `XMLStreamReader`

    - #### getAttributeType

          public String getAttributeType(int index)

      Specified by:
        `getAttributeType` in interface `XMLStreamReader`

    - #### isAttributeSpecified

          public boolean isAttributeSpecified(int index)

      Specified by:
        `isAttributeSpecified` in interface `XMLStreamReader`

    - #### getAttributeValue

          public String getAttributeValue(String namespaceURI,
                                          String localName)

      Specified by:
        `getAttributeValue` in interface `XMLStreamReader`

    - #### getNamespaceURI

          public String getNamespaceURI(String prefix)

      Specified by:
        `getNamespaceURI` in interface `XMLStreamReader`

    - #### getNamespaceCount

          public int getNamespaceCount()

      Specified by:
        `getNamespaceCount` in interface `XMLStreamReader`

    - #### getNamespacePrefix

          public String getNamespacePrefix(int index)

      Specified by:
        `getNamespacePrefix` in interface `XMLStreamReader`

    - #### getNamespaceURI

          public String getNamespaceURI(int index)

      Specified by:
        `getNamespaceURI` in interface `XMLStreamReader`

    - #### getNamespaceContext

          public NamespaceContext getNamespaceContext()

      Specified by:
        `getNamespaceContext` in interface `XMLStreamReader`

    - #### getEventType

          public int getEventType()

      Specified by:
        `getEventType` in interface `XMLStreamReader`

    - #### getEventName

          protected String getEventName()

    - #### getEventData

          protected final Object getEventData()

      Returns:
        raw event data

    - #### getLocation

          public Location getLocation()

      Specified by:
        `getLocation` in interface `XMLStreamReader`

    - #### hasText

          public boolean hasText()

      Specified by:
        `hasText` in interface `XMLStreamReader`

    - #### getText

          public String getText()

      Specified by:
        `getText` in interface `XMLStreamReader`

    - #### getTextCharacters

          public char[] getTextCharacters()

      Specified by:
        `getTextCharacters` in interface `XMLStreamReader`

    - #### getTextCharacters

          public int getTextCharacters(int sourceStart,
                                       char[] target,
                                       int targetStart,
                                       int length)
                                throws XMLStreamException

      Specified by:
        `getTextCharacters` in interface `XMLStreamReader`
      Throws:
        `XMLStreamException`

    - #### getTextStart

          public int getTextStart()

      Specified by:
        `getTextStart` in interface `XMLStreamReader`

    - #### getTextLength

          public int getTextLength()

      Specified by:
        `getTextLength` in interface `XMLStreamReader`

    - #### hasName

          public boolean hasName()

      Specified by:
        `hasName` in interface `XMLStreamReader`

    - #### getName

          public QName getName()

      Specified by:
        `getName` in interface `XMLStreamReader`

    - #### getLocalName

          public String getLocalName()

      Specified by:
        `getLocalName` in interface `XMLStreamReader`

    - #### getNamespaceURI

          public String getNamespaceURI()

      Specified by:
        `getNamespaceURI` in interface `XMLStreamReader`

    - #### getPrefix

          public String getPrefix()

      Specified by:
        `getPrefix` in interface `XMLStreamReader`

    - #### getVersion

          public String getVersion()

      Specified by:
        `getVersion` in interface `XMLStreamReader`

    - #### getEncoding

          public String getEncoding()

      Specified by:
        `getEncoding` in interface `XMLStreamReader`

    - #### isStandalone

          public boolean isStandalone()

      Specified by:
        `isStandalone` in interface `XMLStreamReader`

    - #### standaloneSet

          public boolean standaloneSet()

      Specified by:
        `standaloneSet` in interface `XMLStreamReader`

    - #### getCharacterEncodingScheme

          public String getCharacterEncodingScheme()

      Specified by:
        `getCharacterEncodingScheme` in interface `XMLStreamReader`

    - #### getPITarget

          public String getPITarget()

      Specified by:
        `getPITarget` in interface `XMLStreamReader`

    - #### getPIData

          public String getPIData()

      Specified by:
        `getPIData` in interface `XMLStreamReader`

    - #### getProperty

          public Object getProperty(String name)
                             throws IllegalArgumentException

      Specified by:
        `getProperty` in interface `XMLStreamReader`
      Throws:
        `IllegalArgumentException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2018 Apache Software Foundation. All rights reserved.