Package org.apache.axis2.json
Class AbstractJSONMessageFormatter
java.lang.Object
org.apache.axis2.json.AbstractJSONMessageFormatter
- All Implemented Interfaces:
MessageFormatter
- Direct Known Subclasses:
JSONBadgerfishMessageFormatter,JSONFormatter,JSONMessageFormatter,JSONStreamFormatter
Base class for JSON message formatters.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformatSOAPAction(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, String soapActionString) byte[]getBytes(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format) Gives the JSON message as an array of bytes.getContentType(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, String soapActionString) protected abstract XMLStreamWritergetJSONWriter(Writer writer) protected abstract StringgetStringToWrite(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.getTargetAddress(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, URL targetURL) voidwriteTo(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, OutputStream out, boolean preserve) Writes the JSON message to the output stream with the correct convention.
-
Constructor Details
-
AbstractJSONMessageFormatter
public AbstractJSONMessageFormatter()
-
-
Method Details
-
getContentType
public String getContentType(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, String soapActionString) - Specified by:
getContentTypein interfaceMessageFormatter
-
getBytes
public byte[] getBytes(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format) throws AxisFault 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:
getBytesin interfaceMessageFormatter- 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.
-
formatSOAPAction
public String formatSOAPAction(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, String soapActionString) - Specified by:
formatSOAPActionin interfaceMessageFormatter
-
getJSONWriter
-
getStringToWrite
If the data source is a "Mapped" formatted data source, gives the JSON string by directly taking from the data source.- Parameters:
dataSource- data source to be checked- Returns:
- the JSON string to write
-
writeTo
public void writeTo(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, OutputStream out, boolean preserve) throws AxisFault 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:
writeToin interfaceMessageFormatter- 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.
-
getTargetAddress
public URL getTargetAddress(MessageContext msgCtxt, org.apache.axiom.om.OMOutputFormat format, URL targetURL) throws AxisFault - Specified by:
getTargetAddressin interfaceMessageFormatter- Throws:
AxisFault
-