info.sswap.http.representation.json
Class JsonMessageFactory

java.lang.Object
  extended by info.sswap.http.representation.json.JsonMessageFactory

public class JsonMessageFactory
extends java.lang.Object

Parses a JSON message into its intermediate representation (Message).

Author:
Blazej Bulka

Constructor Summary
JsonMessageFactory()
           
 
Method Summary
private static void initEntityMessage(EntityMessage entityMessage, org.json.JSONObject jsonMessageObject, java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
          Initializes the fields in Entity message based on the data read from JSON.
private static void initMessage(Message message, org.json.JSONObject jsonMessageObject, java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
          Initializes the fields of the most base class (Message) with the data read from JSON.
private static void initPDGMessage(PDGMessage pdgMessage, org.json.JSONObject jsonMessageObject, java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
           
private static void initRDGMessage(ProtocolMessage rdgMessage, org.json.JSONObject jsonMessageObject, java.util.Map<java.lang.String,java.lang.String> overridePrefixes, boolean mappingOptional)
          Initializes the fields in RDG message based on the data read from JSON.
static EntityMessage parseJsonEntityMessage(java.lang.String jsonMessage, java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
          A public method to parse a string that contains an EntityMessage encoded as JSON.
static PDGMessage parseJsonPDGMessage(java.lang.String jsonMessage, java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
           
static ProtocolMessage parseJsonProtocolMessage(java.lang.String jsonMessage, java.util.Map<java.lang.String,java.lang.String> overridePrefixes, boolean optionalMapping)
          A public method to parse a string that contains an SSWAP Canonical Graph (a protocol message) encoded as JSON.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonMessageFactory

public JsonMessageFactory()
Method Detail

initMessage

private static void initMessage(Message message,
                                org.json.JSONObject jsonMessageObject,
                                java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
                         throws org.json.JSONException
Initializes the fields of the most base class (Message) with the data read from JSON. The fields initialized include namespace prefixes and the imports definitions

Parameters:
message - the message object to be initialized
jsonMessageObject - the JSON object describing the message
Throws:
org.json.JSONException - if the JSON has invalid structure

initEntityMessage

private static void initEntityMessage(EntityMessage entityMessage,
                                      org.json.JSONObject jsonMessageObject,
                                      java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
                               throws org.json.JSONException
Initializes the fields in Entity message based on the data read from JSON. This method also requests initialization of the super class of EntityMessage -- Message.

Parameters:
entityMessage - the entity message to be initialized
jsonMessageObject - the JSON object describing the message
Throws:
org.json.JSONException - if the JSON has invalid structure

initRDGMessage

private static void initRDGMessage(ProtocolMessage rdgMessage,
                                   org.json.JSONObject jsonMessageObject,
                                   java.util.Map<java.lang.String,java.lang.String> overridePrefixes,
                                   boolean mappingOptional)
                            throws org.json.JSONException
Initializes the fields in RDG message based on the data read from JSON. This method also requests initialization of RDGMessage's super class -- EntityMessage

Parameters:
rdgMessage - the RDGMessage to be initialized
jsonMessageObject - the JSON object describing the message
Throws:
org.json.JSONException - if the JSON has invalid structure

initPDGMessage

private static void initPDGMessage(PDGMessage pdgMessage,
                                   org.json.JSONObject jsonMessageObject,
                                   java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
                            throws org.json.JSONException
Throws:
org.json.JSONException

parseJsonEntityMessage

public static EntityMessage parseJsonEntityMessage(java.lang.String jsonMessage,
                                                   java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
                                            throws org.json.JSONException
A public method to parse a string that contains an EntityMessage encoded as JSON.

Parameters:
jsonMessage - the string with JSON data
Returns:
the parsed EntityMessage
Throws:
org.json.JSONException - if the JSON cannot be parsed or if it contains invalid structure.

parseJsonProtocolMessage

public static ProtocolMessage parseJsonProtocolMessage(java.lang.String jsonMessage,
                                                       java.util.Map<java.lang.String,java.lang.String> overridePrefixes,
                                                       boolean optionalMapping)
                                                throws org.json.JSONException
A public method to parse a string that contains an SSWAP Canonical Graph (a protocol message) encoded as JSON.

Parameters:
jsonMessage - the string with JSON data
Returns:
the parsed ProtocolMessage
Throws:
org.json.JSONException - if the JSON cannot be parsed or if it contains invalid structure.

parseJsonPDGMessage

public static PDGMessage parseJsonPDGMessage(java.lang.String jsonMessage,
                                             java.util.Map<java.lang.String,java.lang.String> overridePrefixes)
                                      throws org.json.JSONException
Throws:
org.json.JSONException


Copyright (c) 2010, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.