|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sr.common.json.JSONRequest
public class JSONRequest
This class represents an incoming message structure to the remote services. The following Java Script class shows a
sample request message structure.
{
"id":"64f4f4b0-79ee-45f0-9b47-77836bc74ce8",
"method":"service.methodName",
"header":{
"headerField1": "headerVal",
"headerField2": "headerVal",
},
"parameters":{"param1","param2"}
}
Field Summary | |
---|---|
static java.lang.String |
HEADER_ATTRIBUTE
|
static java.lang.String |
METHOD_ATTRIBUTE
|
static java.lang.String |
PARAMETERS_ATTRIBUTE
|
static java.lang.String |
REQUESTID_ATTRIBUTE
|
Constructor Summary | |
---|---|
JSONRequest()
Creates new empty message |
|
JSONRequest(JSONObject jsonReq)
Use this constructor to wrap a prepared message within this class |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
java.util.Map<java.lang.String,java.lang.Object> |
getHeader()
Gives headers as unmodifiable collection |
java.lang.String |
getMethodName()
|
JSONArray |
getParameters()
|
java.lang.String |
getRequestId()
|
java.lang.String |
getServiceName()
|
int |
hashCode()
|
void |
putToHeader(java.lang.String fieldName,
java.lang.Object value)
Adds given field to the header |
void |
removeFromHeader(java.lang.String fieldName)
Removes the requested field form the header |
void |
setEnclosedRequest(JSONObject jsonReq)
Resets all parts of the message and assigns the from the given message parts |
void |
setHeader(java.util.Map<java.lang.String,java.lang.Object> header)
Sets the header part of the message |
void |
setMethodName(java.lang.String methodName)
Assigns the given parameter to the method name. |
void |
setParameters(JSONArray parameters)
Sets given JSONArray as parameters |
void |
setParameters(java.lang.Object[] parameters)
Sets given object array as parameters |
void |
setRequestId(java.lang.String requestId)
Sets the unique request id for the message correlation |
void |
setServiceName(java.lang.String serviceName)
Assigns the given parameter to the service name. |
JSONObject |
toJSON()
Converts message to JSONObject. |
java.lang.String |
toString()
Converts message to java script. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String METHOD_ATTRIBUTE
public static final java.lang.String PARAMETERS_ATTRIBUTE
public static final java.lang.String REQUESTID_ATTRIBUTE
public static final java.lang.String HEADER_ATTRIBUTE
Constructor Detail |
---|
public JSONRequest()
public JSONRequest(JSONObject jsonReq) throws JSONException, TransformationException, TransformationNotSupportedException
jsonReq
- message prepared with javascript notation
JSONException
TransformationException
TransformationNotSupportedException
Method Detail |
---|
public void setEnclosedRequest(JSONObject jsonReq) throws TransformationException, TransformationNotSupportedException
jsonReq
-
TransformationException
TransformationNotSupportedException
public void setServiceName(java.lang.String serviceName) throws JSONException
serviceName
-
JSONException
public void setMethodName(java.lang.String methodName) throws JSONException
methodName
-
JSONException
public void setParameters(java.lang.Object[] parameters) throws JSONException
parameters
-
JSONException
public void setParameters(JSONArray parameters) throws JSONException
parameters
-
JSONException
public void setRequestId(java.lang.String requestId) throws JSONException
requestId
-
JSONException
public void setHeader(java.util.Map<java.lang.String,java.lang.Object> header) throws JSONException, TransformationException, TransformationNotSupportedException
header
-
JSONException
TransformationException
TransformationNotSupportedException
public java.util.Map<java.lang.String,java.lang.Object> getHeader()
public void putToHeader(java.lang.String fieldName, java.lang.Object value) throws JSONException, TransformationException, TransformationNotSupportedException
fieldName
- value
-
JSONException
TransformationException
TransformationNotSupportedException
public void removeFromHeader(java.lang.String fieldName) throws JSONException, TransformationException, TransformationNotSupportedException
fieldName
-
JSONException
TransformationException
TransformationNotSupportedException
public java.lang.String getServiceName()
public java.lang.String getMethodName()
public JSONArray getParameters()
public java.lang.String getRequestId()
public JSONObject toJSON()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |