org.apache.axis2.json
Class AbstractJSONDataSource

java.lang.Object
  extended by 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 OMSourcedElement and can be used either to expand the tree or get the JSON String directly without expanding. This uses the "Mapped" JSON convention.


Field Summary
protected  String localName
           
 
Constructor Summary
AbstractJSONDataSource(Reader jsonReader, String localName)
           
 
Method Summary
 String getCompleteJOSNString()
           
protected  String getJSONString()
           
abstract  XMLStreamReader getReader()
          Gives the StAX reader using the "Mapped" formatted input JSON String.
 void serialize(OutputStream outputStream, org.apache.axiom.om.OMOutputFormat omOutputFormat)
          Writes JSON into the output stream.
 void serialize(Writer writer, org.apache.axiom.om.OMOutputFormat omOutputFormat)
          Writes JSON through the writer.
 void serialize(XMLStreamWriter xmlStreamWriter)
          Writes XML through the XMLStreamWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localName

protected String localName
Constructor Detail

AbstractJSONDataSource

public AbstractJSONDataSource(Reader jsonReader,
                              String localName)
Method Detail

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()


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.