Provides a set of getter methods according to the expected parameter type (number, string, etc.) and whether the parameter is mandatory or optional:
getXXX(param_pos)for mandatory parameters, whereXXXis the expected parameter type.getOptXXX(param_pos, default_value)for optional parameters, specifying a default value.
There are also generic getter methods that let you do the type conversion yourself.
If a parameter cannot be retrieved, e.g. due to a missing mandatory parameter or bad type, a JSONRPC2Error.INVALID_PARAMS exception is thrown.
Example: suppose you have a method with 3 positional parameters where the first two are mandatory and the last is optional and has a default value of true.
// Parse received request string
JSONRPC2Request request = null;
try {
request = JSONRPC2Request.parse(jsonString);
} catch (JSONRPC2ParseException e) {
// handle exception...
}
// Create a new retriever for positional parameters
List params = (List)request.getParams();
PositionalParamsRetriever r = new PositionalParamsRetriever(params);
try {
// Extract first mandatory string parameter
String param1 = r.getString(0);
// Extract second integer parameter
int param2 = r.getInt(1);
// Extract third optional boolean parameter which defaults to true
boolean param3 = r.getOptBoolean(2, true);
} catch (JSONRPC2Error e) {
// A JSONRPC2Error.INVALID_PARAMS will be thrown to indicate
// an unexpected parameter type or a missing mandatory parameter.
// You can use it straight away to create the appropriate
// JSON-RPC 2.0 error response.
JSONRPC2Response response = new JSONRPC2Response(e, null);
}
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionPositionalParamsRetriever(List<Object> params) Creates a new positional parameters retriever from the specified value list.Method Summary
Modifier and TypeMethodDescriptionvoidensureParam(int position) Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position.<T> voidensureParam(int position, Class<T> clazz) Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position, its value isnull, or its type doesn't map to the specified.<T> voidensureParam(int position, Class<T> clazz, boolean allowNull) Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position or its type doesn't map to the specified.get(int position) Retrieves the specified parameter which can be of any type.<T> TRetrieves the specified parameter which must map to the provided class (use the appropriate wrapper class for primitive types).<T> TRetrieves the specified parameter which must map to the provided class (use the appropriate wrapper class for primitive types).booleangetBoolean(int position) Retrieves the specified boolean (maps from JSON true/false) parameter.doublegetDouble(int position) Retrieves the specified numeric parameter as adouble.<T extends Enum<T>>
TRetrieves the specified enumerated parameter (from a JSON string that has a predefined set of possible values).<T extends Enum<T>>
TRetrieves the specified enumerated parameter (from a JSON string that has a predefined set of possible values), allowing for a case insensitive match.getEnumString(int position, String[] enumStrings) Retrieves the specified enumerated string parameter.getEnumString(int position, String[] enumStrings, boolean ignoreCase) Retrieves the specified enumerated string parameter, allowing for a case insensitive match.floatgetFloat(int position) Retrieves the specified numeric parameter as afloat.intgetInt(int position) Retrieves the specified numeric parameter as anint.getList(int position) Retrieves the specified list (maps from JSON array) parameter.getList(int position, boolean allowNull) Retrieves the specified list (maps from JSON array) parameter.longgetLong(int position) Retrieves the specified numeric parameter as along.getMap(int position) Retrieves the specified map (maps from JSON object) parameter.getMap(int position, boolean allowNull) Retrieves the specified map (maps from JSON object) parameter.<T> TRetrieves the specified optional parameter which must map to the provided class (use the appropriate wrapper class for primitive types).<T> TRetrieves the specified optional parameter which must map to the provided class (use the appropriate wrapper class for primitive types).booleangetOptBoolean(int position, boolean defaultValue) Retrieves the specified optional boolean (maps from JSON true/false) parameter.doublegetOptDouble(int position, double defaultValue) Retrieves the specified optional numeric parameter as adouble.<T extends Enum<T>>
TgetOptEnum(int position, Class<T> enumClass, String defaultValue) Retrieves the specified optional enumerated parameter (from a JSON string that has a predefined set of possible values).<T extends Enum<T>>
TgetOptEnum(int position, Class<T> enumClass, String defaultValue, boolean ignoreCase) Retrieves the specified optional enumerated parameter (from a JSON string that has a predefined set of possible values), allowing for a case insensitive match.getOptEnumString(int position, String[] enumStrings, String defaultValue) Retrieves the specified optional enumerated string parameter.getOptEnumString(int position, String[] enumStrings, String defaultValue, boolean ignoreCase) Retrieves the specified optional enumerated string parameter, allowing for a case insensitive match.floatgetOptFloat(int position, float defaultValue) Retrieves the specified optional numeric parameter as afloat.intgetOptInt(int position, int defaultValue) Retrieves the specified optional numeric parameter as anint.getOptList(int position, boolean allowNull, List<Object> defaultValue) Retrieves the specified optional list (maps from JSON array) parameter.getOptList(int position, List<Object> defaultValue) Retrieves the specified optional list (maps from JSON array) parameter.longgetOptLong(int position, long defaultValue) Retrieves the specified optional numeric parameter as along.Retrieves the specified optional map (maps from JSON object) parameter.Retrieves the specified optional map (maps from JSON object) parameter.getOptString(int position, boolean allowNull, String defaultValue) Retrieves the specified optional string parameter.getOptString(int position, String defaultValue) Retrieves the specified optional string parameter.String[]getOptStringArray(int position, boolean allowNull, String[] defaultValue) Retrieves the specified optional string array (maps from JSON array of strings) parameter.String[]getOptStringArray(int position, String[] defaultValue) Retrieves the specified optional string array (maps from JSON array of strings) parameter.Gets the positional parameters for this retriever.getString(int position) Retrieves the specified string parameter.getString(int position, boolean allowNull) Retrieves the specified string parameter.String[]getStringArray(int position) Retrieves the specified string array (maps from JSON array of strings) parameter.String[]getStringArray(int position, boolean allowNull) Retrieves the specified string array (maps from JSON array of strings) parameter.booleanhasParam(int position) Returnstruea parameter at the specified position exists, elsefalse.private static JSONRPC2ErrornewArrayException(int position) Creates a JSON-RPC 2.0 error indicating an array exception.private static JSONRPC2ErrornewUnexpectedParameterTypeException(int position) Creates a JSON-RPC 2.0 error indicating a positional parameter with an unexpected JSON type.intsize()Returns the parameter count.private static <T extends Enum<T>>
voidthrowEnumParameterException(int position, Class<T> enumClass) Throws a JSON-RPC 2.0 error indicating a positional parameter with an unexpected enumerated value.private static voidthrowEnumParameterException(int position, String[] enumStrings) Throws a JSON-RPC 2.0 error indicating a positional parameter with an unexpected enumerated value.private static voidthrowMissingParameterException(int position) Throws a JSON-RPC 2.0 error indicating a missing positional parameter.private static voidthrowNullParameterException(int position) Throws a JSON-RPC 2.0 error indicating a positional parameter with unexpectednullvalue.Methods inherited from class ParamsRetriever
getEnumStringMatch, getEnumStringMatchModifier and TypeMethodDescriptionprotected static <T extends Enum<T>>
TgetEnumStringMatch(String input, Class<T> enumClass, boolean ignoreCase) Matches a string against an enumeration of acceptable values.protected static StringgetEnumStringMatch(String input, String[] enumStrings, boolean ignoreCase) Matches a string against an array of acceptable values.
Field Details
params
Constructor Details
PositionalParamsRetriever
Method Details
throwMissingParameterException
Throws a JSON-RPC 2.0 error indicating a missing positional parameter.- Parameters:
position- The parameter position. Should be non-negative.- Throws:
JSONRPC2Error- Formatted JSON-RPC 2.0 error.
throwNullParameterException
Throws a JSON-RPC 2.0 error indicating a positional parameter with unexpectednullvalue.- Parameters:
position- The parameter position. Should be non-negative.- Throws:
JSONRPC2Error- Formatted JSON-RPC 2.0 error.
throwEnumParameterException
private static void throwEnumParameterException(int position, String[] enumStrings) throws JSONRPC2Error Throws a JSON-RPC 2.0 error indicating a positional parameter with an unexpected enumerated value.- Parameters:
position- The parameter position. Should be non-negative.enumStrings- The acceptable string values. Must not benull.- Throws:
JSONRPC2Error- Formatted JSON-RPC 2.0 error.
throwEnumParameterException
private static <T extends Enum<T>> void throwEnumParameterException(int position, Class<T> enumClass) throws JSONRPC2Error Throws a JSON-RPC 2.0 error indicating a positional parameter with an unexpected enumerated value.- Type Parameters:
T- The enumeration type.- Parameters:
position- The parameter position. Should be non-negative.enumClass- The enumeration class specifying the acceptable string values. Must not benull.- Throws:
JSONRPC2Error- Formatted JSON-RPC 2.0 error.
newUnexpectedParameterTypeException
Creates a JSON-RPC 2.0 error indicating a positional parameter with an unexpected JSON type.- Parameters:
position- The parameter position. Should be non-negative.- Returns:
- Formatted JSON-RPC 2.0 error.
newArrayException
Creates a JSON-RPC 2.0 error indicating an array exception.- Parameters:
position- The parameter position. Should be non-negative.- Returns:
- Formatted JSON-RPC 2.0 error.
getParams
size
public int size()Description copied from class:ParamsRetrieverReturns the parameter count.- Specified by:
sizein classParamsRetriever- Returns:
- The parameters count.
hasParam
public boolean hasParam(int position) Returnstruea parameter at the specified position exists, elsefalse.- Parameters:
position- The parameter position.- Returns:
trueif the parameter exists, elsefalse.
ensureParam
Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position.You may use this method to fire the proper JSON-RPC 2.0 error on a missing mandatory parameter.
- Parameters:
position- The parameter position, starting with zero for the first.- Throws:
JSONRPC2Error- On a missing parameter (JSONRPC2Error.INVALID_PARAMS).
ensureParam
Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position, its value isnull, or its type doesn't map to the specified.You may use this method to fire the proper JSON-RPC 2.0 error on a missing or badly-typed mandatory parameter.
- Type Parameters:
T- The type the parameter value must map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.- Throws:
JSONRPC2Error- On a missing parameter,nullvalue or bad type (JSONRPC2Error.INVALID_PARAMS).
ensureParam
Throws aJSONRPC2Error.INVALID_PARAMSexception if there is no parameter at the specified position or its type doesn't map to the specified.You may use this method to fire the proper JSON-RPC 2.0 error on a missing or badly-typed mandatory parameter.
- Type Parameters:
T- The type the parameter value must map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.allowNull- Iftrueallows anullparameter value.- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
get
Retrieves the specified parameter which can be of any type. Use this generic getter if you want to cast the value yourself. Otherwise look at the typedget*methods.- Parameters:
position- The parameter position.- Returns:
- The parameter value.
- Throws:
JSONRPC2Error- On a missing parameter (JSONRPC2Error.INVALID_PARAMS).
get
Retrieves the specified parameter which must map to the provided class (use the appropriate wrapper class for primitive types).- Type Parameters:
T- The type the parameter value is expected to map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.- Returns:
- The parameter value.
- Throws:
JSONRPC2Error- On a missing parameter,nullvalue or bad type (JSONRPC2Error.INVALID_PARAMS).
get
Retrieves the specified parameter which must map to the provided class (use the appropriate wrapper class for primitive types).- Type Parameters:
T- The type the parameter value is expected to map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.allowNull- Iftrueallows anullparameter value.- Returns:
- The parameter value.
- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
getOpt
Retrieves the specified optional parameter which must map to the provided class (use the appropriate wrapper class for primitive types). If the parameter doesn't exist the method returns the specified default value.- Type Parameters:
T- The type the parameter value is expected to map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value.
- Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOpt
public <T> T getOpt(int position, Class<T> clazz, boolean allowNull, T defaultValue) throws JSONRPC2Error Retrieves the specified optional parameter which must map to the provided class (use the appropriate wrapper class for primitive types). If the parameter doesn't exist the method returns the specified default value.- Type Parameters:
T- The type the parameter value is expected to map to.- Parameters:
position- The parameter position.clazz- The corresponding Java class that the parameter should map to (any one of the return types of thegetXXX()getter methods. Set toObject.classto allow any type. Must not benull.allowNull- Iftrueallows anullparameter value.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value.
- Throws:
JSONRPC2Error- On a bad parameter type (JSONRPC2Error.INVALID_PARAMS).
getString
Retrieves the specified string parameter.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getString
Retrieves the specified string parameter.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
getOptString
Retrieves the specified optional string parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptString
public String getOptString(int position, boolean allowNull, String defaultValue) throws JSONRPC2Error Retrieves the specified optional string parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a bad type (JSONRPC2Error.INVALID_PARAMS).
getEnumString
Retrieves the specified enumerated string parameter.- Parameters:
position- The parameter position.enumStrings- The acceptable string values. Must not benull.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a missing parameter, bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getEnumString
public String getEnumString(int position, String[] enumStrings, boolean ignoreCase) throws JSONRPC2Error Retrieves the specified enumerated string parameter, allowing for a case insensitive match.- Parameters:
position- The parameter position.enumStrings- The acceptable string values. Must not benull.ignoreCase-truefor a case insensitive match.- Returns:
- The matching parameter value as a string.
- Throws:
JSONRPC2Error- On a missing parameter, bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getOptEnumString
public String getOptEnumString(int position, String[] enumStrings, String defaultValue) throws JSONRPC2Error Retrieves the specified optional enumerated string parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.enumStrings- The acceptable string values. Must not benull.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getOptEnumString
public String getOptEnumString(int position, String[] enumStrings, String defaultValue, boolean ignoreCase) throws JSONRPC2Error Retrieves the specified optional enumerated string parameter, allowing for a case insensitive match. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.enumStrings- The acceptable string values. Must not benull.defaultValue- The default return value if the parameter doesn't exist. May benull.ignoreCase-truefor a case insensitive match.- Returns:
- The parameter value as a string.
- Throws:
JSONRPC2Error- On a bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getEnum
Retrieves the specified enumerated parameter (from a JSON string that has a predefined set of possible values).- Type Parameters:
T- The enumeration type that the constant names are resolved in.- Parameters:
position- The parameter position.enumClass- An enumeration type with constant names representing the acceptable string values. Must not benull.- Returns:
- The matching enumeration constant.
- Throws:
JSONRPC2Error- On a missing parameter, bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getEnum
public <T extends Enum<T>> T getEnum(int position, Class<T> enumClass, boolean ignoreCase) throws JSONRPC2Error Retrieves the specified enumerated parameter (from a JSON string that has a predefined set of possible values), allowing for a case insensitive match.- Type Parameters:
T- The enumeration type that the constant names are resolved in.- Parameters:
position- The parameter position.enumClass- An enumeration type with constant names representing the acceptable string values. Must not benull.ignoreCase- Iftruea case insensitive match against the acceptable constant names is performed.- Returns:
- The matching enumeration constant.
- Throws:
JSONRPC2Error- On a missing parameter, bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getOptEnum
public <T extends Enum<T>> T getOptEnum(int position, Class<T> enumClass, String defaultValue) throws JSONRPC2Error Retrieves the specified optional enumerated parameter (from a JSON string that has a predefined set of possible values). If it doesn't exist the method will return the specified default value.- Type Parameters:
T- The enumeration type that the constant names are resolved in.- Parameters:
position- The parameter position.enumClass- An enumeration type with constant names representing the acceptable string values. Must not benull.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The matching enumeration constant.
- Throws:
JSONRPC2Error- On a bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getOptEnum
public <T extends Enum<T>> T getOptEnum(int position, Class<T> enumClass, String defaultValue, boolean ignoreCase) throws JSONRPC2Error Retrieves the specified optional enumerated parameter (from a JSON string that has a predefined set of possible values), allowing for a case insensitive match. If it doesn't exist the method will return the specified default value.- Type Parameters:
T- The enumeration type that the constant names are resolved in.- Parameters:
position- The parameter position.enumClass- An enumeration type with constant names representing the acceptable string values. Must not benull.defaultValue- The default return value if the parameter doesn't exist. May benull.ignoreCase- Iftruea case insensitive match against the acceptable constant names is performed.- Returns:
- The matching enumeration constant.
- Throws:
JSONRPC2Error- On a bad type or bad enumeration value (JSONRPC2Error.INVALID_PARAMS).
getBoolean
Retrieves the specified boolean (maps from JSON true/false) parameter.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a
boolean. - Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptBoolean
Retrieves the specified optional boolean (maps from JSON true/false) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist.- Returns:
- The parameter value as a
boolean. - Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getInt
Retrieves the specified numeric parameter as anint.- Parameters:
position- The parameter position.- Returns:
- The parameter value as an
int. - Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptInt
Retrieves the specified optional numeric parameter as anint. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist.- Returns:
- The parameter value as an
int. - Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getLong
Retrieves the specified numeric parameter as along.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a
long. - Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptLong
Retrieves the specified optional numeric parameter as along. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist.- Returns:
- The parameter value as a
long. - Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getFloat
Retrieves the specified numeric parameter as afloat.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a
float. - Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptFloat
Retrieves the specified optional numeric parameter as afloat. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist.- Returns:
- The parameter value as a
float. - Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getDouble
Retrieves the specified numeric parameter as adouble.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a
double. - Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptDouble
Retrieves the specified optional numeric parameter as adouble. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist.- Returns:
- The parameter value as a
double. - Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getList
Retrieves the specified list (maps from JSON array) parameter.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a list.
- Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getList
Retrieves the specified list (maps from JSON array) parameter.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.- Returns:
- The parameter value as a list.
- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
getOptList
Retrieves the specified optional list (maps from JSON array) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a list.
- Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptList
public List<Object> getOptList(int position, boolean allowNull, List<Object> defaultValue) throws JSONRPC2Error Retrieves the specified optional list (maps from JSON array) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a list.
- Throws:
JSONRPC2Error- On a bad parameter type (JSONRPC2Error.INVALID_PARAMS).
getStringArray
Retrieves the specified string array (maps from JSON array of strings) parameter.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a string array.
- Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getStringArray
Retrieves the specified string array (maps from JSON array of strings) parameter.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.- Returns:
- The parameter value as a string array.
- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
getOptStringArray
Retrieves the specified optional string array (maps from JSON array of strings) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a string array.
- Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptStringArray
public String[] getOptStringArray(int position, boolean allowNull, String[] defaultValue) throws JSONRPC2Error Retrieves the specified optional string array (maps from JSON array of strings) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a string array.
- Throws:
JSONRPC2Error- On a bad parameter type (JSONRPC2Error.INVALID_PARAMS).
getMap
Retrieves the specified map (maps from JSON object) parameter.- Parameters:
position- The parameter position.- Returns:
- The parameter value as a map.
- Throws:
JSONRPC2Error- On a missing parameter, bad type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getMap
Retrieves the specified map (maps from JSON object) parameter.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.- Returns:
- The parameter value as a map.
- Throws:
JSONRPC2Error- On a missing parameter or bad type (JSONRPC2Error.INVALID_PARAMS).
getOptMap
public Map<String,Object> getOptMap(int position, Map<String, Object> defaultValue) throws JSONRPC2ErrorRetrieves the specified optional map (maps from JSON object) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a map.
- Throws:
JSONRPC2Error- On a bad parameter type ornullvalue (JSONRPC2Error.INVALID_PARAMS).
getOptMap
public Map<String,Object> getOptMap(int position, boolean allowNull, Map<String, Object> defaultValue) throws JSONRPC2ErrorRetrieves the specified optional map (maps from JSON object) parameter. If it doesn't exist the method will return the specified default value.- Parameters:
position- The parameter position.allowNull- Iftrueallows anullvalue.defaultValue- The default return value if the parameter doesn't exist. May benull.- Returns:
- The parameter value as a map.
- Throws:
JSONRPC2Error- On a bad parameter type (JSONRPC2Error.INVALID_PARAMS).