org.apache.axis2.json
Class JSONFormatter
java.lang.Object
org.apache.axis2.json.AbstractJSONMessageFormatter
org.apache.axis2.json.JSONFormatter
- All Implemented Interfaces:
- MessageFormatter
public class JSONFormatter
- extends AbstractJSONMessageFormatter
|
Method Summary |
byte[] |
getBytes(MessageContext msgCtxt,
org.apache.axiom.om.OMOutputFormat format)
Gives the JSON message as an array of bytes. |
protected javax.xml.stream.XMLStreamWriter |
getJSONWriter(java.io.Writer writer)
|
protected java.lang.String |
getStringToWrite(org.apache.axiom.om.OMDataSource dataSource)
If the data source is a "Mapped" formatted data source, gives the JSON string by directly
taking from the data source. |
void |
writeTo(MessageContext msgCtxt,
org.apache.axiom.om.OMOutputFormat format,
java.io.OutputStream out,
boolean preserve)
Writes the JSON message to the output stream with the correct convention. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JSONFormatter
public JSONFormatter()
getBytes
public byte[] getBytes(MessageContext msgCtxt,
org.apache.axiom.om.OMOutputFormat format)
throws AxisFault
- Description copied from class:
AbstractJSONMessageFormatter
- Gives the JSON message as an array of bytes. If the payload is an OMSourcedElementImpl and
it contains a JSONDataSource with a correctly formatted JSON String, gets it directly from
the DataSource and returns as a byte array. If not, the OM tree is expanded and it is
serialized into the output stream and byte array is returned.
- Specified by:
getBytes in interface MessageFormatter- Overrides:
getBytes in class AbstractJSONMessageFormatter
- Parameters:
msgCtxt - Message context which contains the soap envelope to be writtenformat - format of the message, this is ignored
- Returns:
- the payload as a byte array
- Throws:
AxisFault - if there is an error in writing the message using StAX writer or IF THE
USER TRIES TO SEND A JSON MESSAGE WITH NAMESPACES USING THE "MAPPED"
CONVENTION.
writeTo
public void writeTo(MessageContext msgCtxt,
org.apache.axiom.om.OMOutputFormat format,
java.io.OutputStream out,
boolean preserve)
throws AxisFault
- Description copied from class:
AbstractJSONMessageFormatter
- Writes the JSON message to the output stream with the correct convention. If the payload is
an OMSourcedElementImpl and it contains a JSONDataSource with a correctly formatted JSON
String, gets it directly from the DataSource and writes to the output stream. If not, the OM
tree is expanded and it is serialized into the output stream. *
- Specified by:
writeTo in interface MessageFormatter- Overrides:
writeTo in class AbstractJSONMessageFormatter
- Parameters:
msgCtxt - Message context which contains the soap envelope to be writtenformat - format of the message, this is ignoredout - output stream to be written in topreserve - ignored
- Throws:
AxisFault - if there is an error in writing the message using StAX writer or IF THE
USER TRIES TO SEND A JSON MESSAGE WITH NAMESPACES USING THE "MAPPED"
CONVENTION.
getJSONWriter
protected javax.xml.stream.XMLStreamWriter getJSONWriter(java.io.Writer writer)
- Specified by:
getJSONWriter in class AbstractJSONMessageFormatter
getStringToWrite
protected java.lang.String getStringToWrite(org.apache.axiom.om.OMDataSource dataSource)
- Description copied from class:
AbstractJSONMessageFormatter
- If the data source is a "Mapped" formatted data source, gives the JSON string by directly
taking from the data source.
- Specified by:
getStringToWrite in class AbstractJSONMessageFormatter
- Parameters:
dataSource - data source to be checked
- Returns:
- the JSON string to write
Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.