Class AbstractJSONDataSource

java.lang.Object
org.apache.axis2.json.AbstractJSONDataSource
All Implemented Interfaces:
org.apache.axiom.om.OMDataSource
Direct Known Subclasses:
JSONBadgerfishDataSource, JSONDataSource

public abstract class AbstractJSONDataSource extends Object implements org.apache.axiom.om.OMDataSource
JSONDataSource keeps the JSON String inside and consumes it when needed. This is to be kept in the OMSourcedElementImpl and can be used either to expand the tree or get the JSON String directly without expanding. This uses the "Mapped" JSON convention.
  • Field Details

    • localName

      protected String localName
  • Constructor Details

    • AbstractJSONDataSource

      public AbstractJSONDataSource(Reader jsonReader, String localName)
  • Method Details

    • serialize

      public void serialize(OutputStream outputStream, org.apache.axiom.om.OMOutputFormat omOutputFormat) throws XMLStreamException
      Writes JSON into the output stream. As this should write JSON, it directly gets the JSON string and writes it without expanding the tree.
      Specified by:
      serialize in interface org.apache.axiom.om.OMDataSource
      Parameters:
      outputStream - the stream to be written into
      omOutputFormat - format of the message, this is ignored.
      Throws:
      XMLStreamException - if there is an error while writing the message in to the output stream.
    • serialize

      public void serialize(Writer writer, org.apache.axiom.om.OMOutputFormat omOutputFormat) throws XMLStreamException
      Writes JSON through the writer. As this should write JSON, it directly gets the JSON string and writes it without expanding the tree.
      Specified by:
      serialize in interface org.apache.axiom.om.OMDataSource
      Parameters:
      writer - Writer to be written into
      omOutputFormat - format of the message, this is ignored.
      Throws:
      XMLStreamException - if there is an error while writing the message through the writer.
    • serialize

      public void serialize(XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes XML through the XMLStreamWriter. As the input data source is JSON, this method needs to get a StAX reader from that JSON String. Therefore this uses the getReader() method to get the StAX reader writes the events into the XMLStreamWriter.
      Specified by:
      serialize in interface org.apache.axiom.om.OMDataSource
      Parameters:
      xmlStreamWriter - StAX writer to be written into
      Throws:
      XMLStreamException - if there is an error while writing the message through the StAX writer.
    • getReader

      public abstract XMLStreamReader getReader() throws XMLStreamException
      Gives the StAX reader using the "Mapped" formatted input JSON String.
      Specified by:
      getReader in interface org.apache.axiom.om.OMDataSource
      Returns:
      The XMLStreamReader according to the JSON String.
      Throws:
      XMLStreamException - if there is an error while making the StAX reader.
    • getJSONString

      protected String getJSONString()
    • getCompleteJOSNString

      public String getCompleteJOSNString()