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:
    javax.xml.stream.XMLStreamConstants, javax.xml.stream.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.
    `java.lang.Boolean` | `getBoolean()`
    `java.lang.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 javax.xml.stream.XMLStreamException

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

    - #### JsonXMLStreamReader

          public JsonXMLStreamReader(JsonStreamSource source,
                                     boolean multiplePI,
                                     char namespaceSeparator,
                                     boolean xmlNilReadWriteEnabled)
                              throws javax.xml.stream.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:
        `javax.xml.stream.XMLStreamException`

  - ### Method Detail

    - #### consume

          protected boolean consume()
                             throws javax.xml.stream.XMLStreamException,
                                    java.io.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:
        `javax.xml.stream.XMLStreamException`
        `java.io.IOException`

    - #### hasNumber

          public boolean hasNumber()

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

    - #### getNumber

          public java.lang.Number getNumber()

      Returns:
        number primitive
      Throws:
        `java.lang.ClassCastException`

    - #### hasBoolean

          public boolean hasBoolean()

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

    - #### getBoolean

          public java.lang.Boolean getBoolean()

      Returns:
        boolean primitive
      Throws:
        `java.lang.ClassCastException`

    - #### close

          public void close()
                     throws javax.xml.stream.XMLStreamException

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

Copyright © 2005-2021 Apache Software Foundation. All Rights Reserved.