org.apache.axis2.json
Class JSONDataSource

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

public class JSONDataSource
extends java.lang.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 Summary
protected  java.lang.String localName
           
 
Constructor Summary
JSONDataSource(java.io.InputStream jsonInputStream, java.lang.String localName)
           
 
Method Summary
 java.lang.String getCompleteJOSNString()
           
protected  java.lang.String getJSONString()
           
 javax.xml.stream.XMLStreamReader getReader()
          Gives the StAX reader using the "Mapped" formatted input JSON String.
 void serialize(java.io.OutputStream outputStream, org.apache.axiom.om.OMOutputFormat omOutputFormat)
          Writes JSON into the output stream.
 void serialize(java.io.Writer writer, org.apache.axiom.om.OMOutputFormat omOutputFormat)
          Writes JSON through the writer.
 void serialize(javax.xml.stream.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 java.lang.String localName
Constructor Detail

JSONDataSource

public JSONDataSource(java.io.InputStream jsonInputStream,
                      java.lang.String localName)
Method Detail

serialize

public void serialize(java.io.OutputStream outputStream,
                      org.apache.axiom.om.OMOutputFormat omOutputFormat)
               throws javax.xml.stream.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:
javax.xml.stream.XMLStreamException - if there is an error while writing the message in to the output stream.

serialize

public void serialize(java.io.Writer writer,
                      org.apache.axiom.om.OMOutputFormat omOutputFormat)
               throws javax.xml.stream.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:
javax.xml.stream.XMLStreamException - if there is an error while writing the message through the writer.

serialize

public void serialize(javax.xml.stream.XMLStreamWriter xmlStreamWriter)
               throws javax.xml.stream.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:
javax.xml.stream.XMLStreamException - if there is an error while writing the message through the StAX writer.

getReader

public javax.xml.stream.XMLStreamReader getReader()
                                           throws javax.xml.stream.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:
javax.xml.stream.XMLStreamException - if there is an error while making the StAX reader.

getJSONString

protected java.lang.String getJSONString()

getCompleteJOSNString

public java.lang.String getCompleteJOSNString()


Copyright © 2007 Apache Web Services Project. All Rights Reserved.