Package org.whiteflagprotocol.java.util
Class WfJsonMessage
java.lang.Object
org.whiteflagprotocol.java.util.WfJsonMessage
Whiteflag JSON message representation class
This class represents a Whiteflag message represented in the
JavaScript Object Notation (JSON) format, in accordance with Annex B
of the Whiteflag specification. The basic JSON structure is as follows:
{ "MetaHeader" : {...}, "MessageHeader": {...}, "MessageBody": {...} }
- Since:
- 1.0
- Whiteflag standard x-reference:
- Annex B. JSON Schema of Whiteflag Messages
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic WfJsonMessage
Creates a new JSON representation of a Whiteflag message from a serialized JSON stringgetBody()
Gets the message bodyGets the message headerGets the message metadatatoJson()
Creates a serialized JSON representation of a Whiteflag message
-
Constructor Details
-
WfJsonMessage
public WfJsonMessage(Map<String, String> metadata, Map<String, String> header, Map<String, String> body) Creates a new JSON representation of a Whiteflag message- Parameters:
metadata
- the key-to-value mapping of metadataheader
- the fieldname-to-value mapping of the message headerbody
- the fieldname-to-value mapping of message body
-
-
Method Details
-
create
Creates a new JSON representation of a Whiteflag message from a serialized JSON string- Parameters:
jsonStr
- a JSON representation of a Whiteflag message- Returns:
- a JSON message
- Throws:
WfUtilException
- if JSON is invalid
-
getMetadata
Gets the message metadata- Returns:
- the key-to-value mapping of the message metadata
-
getHeader
Gets the message header- Returns:
- the fieldname-to-value mapping of the message header
-
getBody
Gets the message body- Returns:
- the fieldname-to-value mapping of the message body
-
toJson
Creates a serialized JSON representation of a Whiteflag message- Returns:
- the serialized JSON representation of the message
- Throws:
WfUtilException
- if no valid JSON serialization can be created
-