Package ratpack.core.parse
Interface Parser<O>
-
- Type Parameters:
O
- the type of option object this parser accepts
- All Known Implementing Classes:
NoOptParserSupport
,ParserSupport
public interface Parser<O>
A parser converts a request body into an object.Parsers power the
Context.parse(Parse)
mechanism.The
ParserSupport
class is a convenient base; the documentation of which contains implementation examples.- See Also:
Parse
,ParserSupport
,NoOptParserSupport
,Context.parse(Parse)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Class<O>
getOptsType()
The type of option object that this parser accepts.<T> T
parse(Context context, TypedData requestBody, Parse<T,O> parse)
Deserializes the request body of the context into an object.
-
-
-
Method Detail
-
getOptsType
Class<O> getOptsType()
The type of option object that this parser accepts.- Returns:
- the type of option object that this parser accepts
- See Also:
ParserSupport
-
parse
@Nullable <T> T parse(Context context, TypedData requestBody, Parse<T,O> parse) throws Exception
Deserializes the request body of the context into an object.- Type Parameters:
T
- the type of object to construct from the request body- Parameters:
context
- The context to deserializerequestBody
- The request body to deserializeparse
- The description of how to parse the request body- Returns:
- The object representation of the request body, or
null
if this parser cannot parse to the requested type - Throws:
Exception
- if an error occurs parsing the request
-
-