Class Deserializer
java.lang.Object
cz.metacentrum.perun.rpc.deserializer.Deserializer
- Direct Known Subclasses:
JsonDeserializer
,UrlDeserializer
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.- Author:
- Jan Klos invalid input: '<'ddd@mail.muni.cz>, Pavel Zlamal invalid input: '<'256627@mail.muni.cz>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Returnstrue
if value with the specified name is supplied.jakarta.servlet.http.HttpServletRequest
Return HttpServletRequest related to concrete call this deserializer is used to process.<T> T
Reads value from root Json node.<T> T
Reads value with the specified name asvalueType
.abstract String
readAll()
Returns string representation of the variables stored in the deserializer.int[]
readArrayOfInts
(String name) abstract Boolean
readBoolean
(String name) Reads value with the specified name asBoolean
.abstract int
Reads value with the specified name asint
.<T> List
<T> Reads array from root Json node.<T> List
<T> Reads array with the specified name asList<valueType>
.readListPerunBeans
(String name) Reads array with the specified name asList<PerunBean>
.readLocalDate
(String name) Reads LocalDate value with the specified name.readPerunBean
(String name) Reads value with the specified name asPerunBean
.abstract String
readString
(String name) Reads value with the specified name asString
.abstract UUID
Reads value with the specified name asUUID
.void
Check whether method that changes state is not GET.
-
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
-
getServletRequest
public jakarta.servlet.http.HttpServletRequest getServletRequest()Return HttpServletRequest related to concrete call this deserializer is used to process.Note that this "request" is not necessarily used as source to read parameters by other methods of deserializer. It IS typically for GET requests, but NOT for POST with JSON/JSONP data format.
- Returns:
- HttpServletRequest related to concrete call
- Throws:
UnsupportedOperationException
- if this deserializer does not implement this method
-
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 from root Json node.- 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
-
readAll
Returns string representation of the variables stored in the deserializer.- Returns:
- string containing all variables
- Throws:
RpcException
-
readArrayOfInts
-
readBoolean
Reads value with the specified name asBoolean
.- Parameters:
name
- name of the value to read- Returns:
- the value as
Boolean
- Throws:
RpcException
- If the specified value cannot be parsed asString
or if it is not supplied
-
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
-
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 array from root Json node.- 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
-
readListPerunBeans
Reads array with the specified name asList<PerunBean>
.- Parameters:
name
- name of the array to read- Returns:
- the value as
List<PerunBean>
- Throws:
UnsupportedOperationException
- if this deserializer does not implement this methodRpcException
- if the specified value cannot be parsed asperunBean
or if it is not supplied
-
readLocalDate
Reads LocalDate value with the specified name. Expected ISO-8601 format. (yyyy-MM-dd)- Parameters:
name
- name of the localDate value- Returns:
- parsed local date
-
readPerunBean
Reads value with the specified name asPerunBean
.- Parameters:
name
- name of the value to read- Returns:
- the value as
PerunBean
- Throws:
UnsupportedOperationException
- if this deserializer does not implement this methodRpcException
- if the specified value cannot be parsed asperunBean
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
-
readUUID
Reads value with the specified name asUUID
.- Parameters:
name
- name of the value to read- Returns:
- the value as
UUID
- Throws:
RpcException
- If the specified value cannot be parsed asUUID
or if it is not supplied
-
stateChangingCheck
public void stateChangingCheck()Check whether method that changes state is not GET.- Throws:
RpcException
- if method is GET
-