Package eu.woolplatform.utils.json.rpc
Class JsonRpcRequest
- java.lang.Object
-
- eu.woolplatform.utils.json.rpc.JsonRpcMessage
-
- eu.woolplatform.utils.json.rpc.JsonRpcRequest
-
public class JsonRpcRequest extends JsonRpcMessage
This class models a JSON-RPC Request.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonRpcRequestcreate(String method, Object id)Creates a new JSON-RPC request without parameters.static JsonRpcRequestcreate(String method, List<?> params, Object id)Creates a new JSON-RPC request with parameters as a JSON array.static JsonRpcRequestcreate(String method, Map<String,?> params, Object id)Creates a new JSON-RPC request with parameters as a JSON object.ObjectgetID()Returns the request ID (string, number or null).List<?>getListParams()Returns the parameters, if the request contains parameters as a JSON array.Map<?,?>getMapParams()Returns the parameters, if the request contains parameters as a JSON object.StringgetMethod()Returns the method name.static JsonRpcRequestread(Map<?,?> map)Reads a JSON-RPC request from the specified map, which should represent a JSON object.StringtoString()voidwrite(Writer out)Writes this message as a JSON string to the specified writer.
-
-
-
Method Detail
-
read
public static JsonRpcRequest read(Map<?,?> map) throws ParseException
Reads a JSON-RPC request from the specified map, which should represent a JSON object.- Parameters:
map- the map- Returns:
- the request
- Throws:
ParseException- if the map is not a valid JSON-RPC request- See Also:
JsonRpcMessage.read(Map)
-
create
public static JsonRpcRequest create(String method, Object id)
Creates a new JSON-RPC request without parameters.- Parameters:
method- the method nameid- the request ID (string, number or null)- Returns:
- the request
-
create
public static JsonRpcRequest create(String method, Map<String,?> params, Object id)
Creates a new JSON-RPC request with parameters as a JSON object.- Parameters:
method- the method nameparams- the parametersid- the request ID (string, number or null)- Returns:
- the request
-
create
public static JsonRpcRequest create(String method, List<?> params, Object id)
Creates a new JSON-RPC request with parameters as a JSON array.- Parameters:
method- the method nameparams- the parametersid- the request ID (string, number or null)- Returns:
- the request
-
getMethod
public String getMethod()
Returns the method name.- Returns:
- the method name
-
getMapParams
public Map<?,?> getMapParams()
Returns the parameters, if the request contains parameters as a JSON object. If the request has no parameters, or it has parameters as a JSON array, this method returns null.- Returns:
- the parameters as a JSON object or null
- See Also:
getListParams()
-
getListParams
public List<?> getListParams()
Returns the parameters, if the request contains parameters as a JSON array. If the request has no parameters, or it has parameters as a JSON object, this method returns null.- Returns:
- the parameters as a JSON array or null
- See Also:
getMapParams()
-
getID
public Object getID()
Returns the request ID (string, number or null).- Returns:
- the request ID (string, number or null)
-
write
public void write(Writer out) throws IOException
Description copied from class:JsonRpcMessageWrites this message as a JSON string to the specified writer.- Specified by:
writein classJsonRpcMessage- Parameters:
out- the writer- Throws:
IOException- if a writing error occurs
-
toString
public String toString()
- Overrides:
toStringin classJsonRpcMessage
-
-