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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanReturnstrueif value with the specified name is supplied.jakarta.servlet.http.HttpServletRequestReturn HttpServletRequest related to concrete call this deserializer is used to process.<T> TReads value from root Json node.<T> TReads value with the specified name asvalueType.abstract StringreadAll()Returns string representation of the variables stored in the deserializer.int[]readArrayOfInts(String name) abstract BooleanreadBoolean(String name) Reads value with the specified name asBoolean.abstract intReads 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 StringreadString(String name) Reads value with the specified name asString.abstract UUIDReads value with the specified name asUUID.voidCheck whether method that changes state is not GET.
-
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
-
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 asvalueTypeor 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 asvalueTypeor 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 asStringor 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 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 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 asvalueTypeor 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 asperunBeanor 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 asperunBeanor 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
-
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 asUUIDor if it is not supplied
-
stateChangingCheck
public void stateChangingCheck()Check whether method that changes state is not GET.- Throws:
RpcException- if method is GET
-