org.apache.synapse.commons.staxon.core.json

## Class JsonXMLStreamReader

- java.lang.Object
- - org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader<org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.ScopeInfo>
  - - org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader

- All Implemented Interfaces:
    XMLStreamConstants, XMLStreamReader

      public class JsonXMLStreamReader
      extends AbstractXMLStreamReader<org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.ScopeInfo>

  JSON XML stream reader.

  #### Limitations

  - Mixed content (e.g. `<alice>bob<edgar/></alice>`) is not supported.

  The reader may produce processing instructions `<?xml-multiple element-name?>` to indicate array starts (`'['`).

- - ### 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
    `JsonXMLStreamReader(JsonStreamSource source, boolean multiplePI, char namespaceSeparator)` Create reader instance.
    `JsonXMLStreamReader(JsonStreamSource source, boolean multiplePI, char namespaceSeparator, boolean xmlNilReadWriteEnabled)` Create reader instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected boolean` | `consume()` Main method to be implemented by subclasses.
    `Boolean` | `getBoolean()`
    `Number` | `getNumber()`
    `boolean` | `hasBoolean()`
    `boolean` | `hasNumber()`

    - ### Methods inherited from class org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader

      `getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventData, getEventName, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getScope, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, initialize, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartDocumentRead, isStartElement, isWhiteSpace, next, nextTag, readAttr, readData, readEndDocument, readEndElementTag, readNsDecl, readPI, readStartDocument, readStartElementTag, require, standaloneSet, toString`

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

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

- - ### Constructor Detail

    - #### JsonXMLStreamReader

          public JsonXMLStreamReader(JsonStreamSource source,
                                     boolean multiplePI,
                                     char namespaceSeparator)
                              throws XMLStreamException

      Create reader instance.
      Parameters:
        `source` - stream source
        `multiplePI` - whether to produce `<xml-multiple?>` PIs to signal array start
        `namespaceSeparator` - namespace prefix separator
      Throws:
        `XMLStreamException`

    - #### JsonXMLStreamReader

          public JsonXMLStreamReader(JsonStreamSource source,
                                     boolean multiplePI,
                                     char namespaceSeparator,
                                     boolean xmlNilReadWriteEnabled)
                              throws XMLStreamException

      Create reader instance.
      Parameters:
        `source` - stream source
        `multiplePI` - whether to produce `<xml-multiple?>` PIs to signal array start
        `namespaceSeparator` - namespace prefix separator
        `xmlNilReadWriteEnabled` - Supports reading and writing of XML Nil elements as defined by http://www.w3.org/TR/xmlschema-1/#xsi_nil when the XML/JSON inputs contains nil/null values.
      Throws:
        `XMLStreamException`

  - ### Method Detail

    - #### consume

          protected boolean consume()
                             throws XMLStreamException,
                                    IOException

      Description copied from class: `AbstractXMLStreamReader`
      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.
      Specified by:
        `consume` in class `AbstractXMLStreamReader<org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.ScopeInfo>`
      Returns:
        `true` if there's more to read
      Throws:
        `XMLStreamException`
        `IOException`

    - #### hasNumber

          public boolean hasNumber()

      Returns:
        `true` iff the current event data is a number primitive

    - #### getNumber

          public Number getNumber()

      Returns:
        number primitive
      Throws:
        `ClassCastException`

    - #### hasBoolean

          public boolean hasBoolean()

      Returns:
        `true` iff the current event data is a boolean primitive

    - #### getBoolean

          public Boolean getBoolean()

      Returns:
        boolean primitive
      Throws:
        `ClassCastException`

    - #### close

          public void close()
                     throws XMLStreamException

      Specified by:
        `close` in interface `XMLStreamReader`
      Overrides:
        `close` in class `AbstractXMLStreamReader<org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.ScopeInfo>`
      Throws:
        `XMLStreamException`

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