Package cz.metacentrum.perun.rpclib.api
Class Deserializer
java.lang.Object
cz.metacentrum.perun.rpclib.api.Deserializer
- Direct Known Subclasses:
JsonDeserializer
Subclasses of
Deserializer class provide methods to deserialize values supplied as name/value pairs in some
form (ie. in JSON or as HTTP request parameters). It is presumed that the names of the values are unique - results
are undefined if multiple values with the same name are supplied. Implementing any of the read* methods is optional.- Since:
- 0.1
- Author:
- Jan Klos invalid input: '<'ddd@mail.muni.cz>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanReturnstrueif value with the specified name is supplied.<T> TReads value asvalueType.<T> TReads value with the specified name asvalueType.int[]int[]readArrayOfInts(String name) abstract intreadInt()Reads value asint.abstract intReads value with the specified name asint.<T> List<T> Reads an arrayList<valueType>.<T> List<T> Reads array with the specified name asList<valueType>.abstract StringReads value asString.abstract StringreadString(String name) Reads value with the specified name asString.
-
Constructor Details
-
Deserializer
public Deserializer()
-
-
Method Details
-
contains
Returnstrueif value with the specified name is supplied.- Parameters:
name- name of the value to check- Returns:
trueif value with the specified name is supplied,falseotherwise
-
read
Reads value with the specified name asvalueType.- Parameters:
name- name of the value to readvalueType- type of the value to read- Returns:
- the value as
valueType - Throws:
UnsupportedOperationException- if this deserializer does not implement this methodRpcException- if the specified value cannot be parsed asvalueTypeor if it is not supplied
-
read
Reads value asvalueType.- Parameters:
valueType- type of the value to read- Returns:
- the value as
valueType - Throws:
UnsupportedOperationException- if this deserializer does not implement this methodRpcException- if the specified value cannot be parsed asvalueTypeor if it is not supplied
-
readArrayOfInts
-
readArrayOfInts
public int[] readArrayOfInts() -
readInt
Reads value with the specified name asint.- Parameters:
name- name of the value to read- Returns:
- the value as
int - Throws:
RpcException- if the specified value cannot be parsed asintor if it is not supplied
-
readInt
public abstract int readInt()Reads value asint.- Returns:
- the value as
int - Throws:
RpcException- if the specified value cannot be parsed asintor if it is not supplied
-
readList
Reads array with the specified name asList<valueType>.- Parameters:
name- name of the array to readvalueType- type of the value to read- Returns:
- the value as
List<valueType> - Throws:
UnsupportedOperationException- if this deserializer does not implement this methodRpcException- if the specified value cannot be parsed asvalueTypeor if it is not supplied
-
readList
Reads an arrayList<valueType>.- Parameters:
valueType- type of the value to read- Returns:
- the value as
List<valueType> - Throws:
UnsupportedOperationException- if this deserializer does not implement this methodRpcException- if the specified value cannot be parsed asvalueTypeor if it is not supplied
-
readString
Reads value with the specified name asString.- Parameters:
name- name of the value to read- Returns:
- the value as
String - Throws:
RpcException- If the specified value cannot be parsed asStringor if it is not supplied
-
readString
Reads value asString.- Returns:
- the value as
String - Throws:
RpcException- If the specified value cannot be parsed asStringor if it is not supplied
-