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
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Returnstrue
if value with the specified name is supplied.<T> T
Reads value asvalueType
.<T> T
Reads value with the specified name asvalueType
.int[]
int[]
readArrayOfInts
(String name) abstract int
readInt()
Reads value asint
.abstract int
Reads 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 String
Reads value asString
.abstract String
readString
(String name) Reads value with the specified name asString
.
-
Constructor Details
-
Deserializer
public Deserializer()
-
-
Method Details
-
contains
Returnstrue
if value with the specified name is supplied.- Parameters:
name
- name of the value to check- Returns:
true
if value with the specified name is supplied,false
otherwise
-
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 asvalueType
or 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 asvalueType
or 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 asint
or 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 asint
or 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 asvalueType
or 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 asvalueType
or 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 asString
or if it is not supplied
-
readString
Reads value asString
.- Returns:
- the value as
String
- Throws:
RpcException
- If the specified value cannot be parsed asString
or if it is not supplied
-