Package ratpack.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
ParserSupportclass 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 java.lang.Class<O>getOptsType()The type of option object that this parser accepts.<T> Tparse(Context context, TypedData requestBody, Parse<T,O> parse)Deserializes the request body of the context into an object.
-
-
-
Method Detail
-
getOptsType
java.lang.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 java.lang.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
nullif this parser cannot parse to the requested type - Throws:
java.lang.Exception- if an error occurs parsing the request
-
-