Package eu.woolplatform.utils.json.rpc
Class JsonRpcNotification
- java.lang.Object
-
- eu.woolplatform.utils.json.rpc.JsonRpcMessage
-
- eu.woolplatform.utils.json.rpc.JsonRpcNotification
-
public class JsonRpcNotification extends JsonRpcMessage
This class models a JSON-RPC Notification.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonRpcNotificationcreate(String method)Creates a new JSON-RPC notification without parameters.static JsonRpcNotificationcreate(String method, List<?> params)Creates a new JSON-RPC notification with parameters as a JSON array.static JsonRpcNotificationcreate(String method, Map<String,?> params)Creates a new JSON-RPC notification with parameters as a JSON object.List<?>getListParams()Returns the parameters, if the notification contains parameters as a JSON array.Map<?,?>getMapParams()Returns the parameters, if the notification contains parameters as a JSON object.StringgetMethod()Returns the method name.static JsonRpcNotificationread(Map<?,?> map)Reads a JSON-RPC notification 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 JsonRpcNotification read(Map<?,?> map) throws ParseException
Reads a JSON-RPC notification from the specified map, which should represent a JSON object.- Parameters:
map- the map- Returns:
- the notification
- Throws:
ParseException- if the map is not a valid JSON-RPC notification- See Also:
JsonRpcMessage.read(Map)
-
create
public static JsonRpcNotification create(String method)
Creates a new JSON-RPC notification without parameters.- Parameters:
method- the method name- Returns:
- the notification
-
create
public static JsonRpcNotification create(String method, Map<String,?> params)
Creates a new JSON-RPC notification with parameters as a JSON object.- Parameters:
method- the method nameparams- the parameters- Returns:
- the notification
-
create
public static JsonRpcNotification create(String method, List<?> params)
Creates a new JSON-RPC notification with parameters as a JSON array.- Parameters:
method- the method nameparams- the parameters- Returns:
- the notification
-
getMethod
public String getMethod()
Returns the method name.- Returns:
- the method name
-
getMapParams
public Map<?,?> getMapParams()
Returns the parameters, if the notification contains parameters as a JSON object. If the notification 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 notification contains parameters as a JSON array. If the notification 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()
-
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
-
-