org.jboss.aerogear.controller.util
Class ParameterExtractor
java.lang.Object
org.jboss.aerogear.controller.util.ParameterExtractor
public class ParameterExtractor
- extends Object
|
Field Summary |
private static br.com.caelum.iogi.Iogi |
IOGI
|
|
Method Summary |
private static boolean |
addIfPresent(com.google.common.base.Optional<?> op,
String paramName,
Map<String,Object> args)
|
private static Object |
createInstance(Class<?> type,
String arg)
|
static Map<String,Object> |
extractArguments(RouteContext routeContext,
Map<String,Consumer> consumers)
Extracts the arguments from the current request for the target route. |
private static Object |
extractBody(RouteContext routeContext,
Parameter<?> parameter,
Consumer consumer)
|
private static com.google.common.base.Optional<String> |
extractContentType(RouteContext routeContext)
|
private static com.google.common.base.Optional<?> |
extractCookieParam(RouteContext routeContext,
String paramName,
Class<?> type)
|
private static com.google.common.base.Optional<?> |
extractDefaultParam(Class<?> type,
com.google.common.base.Optional<?> defaultValue)
|
private static com.google.common.base.Optional<?> |
extractHeaderParam(RouteContext routeContext,
String paramName)
|
static com.google.common.base.Optional<?> |
extractIogiParam(RouteContext routeContext)
Returns an instance of the type used in the parameter names using Iogi. |
private static com.google.common.base.Optional<?> |
extractParam(RouteContext routeContext,
String name,
Class<?> type)
|
static com.google.common.base.Optional<?> |
extractPathParam(RouteContext routeContext,
RequestParameter<?> param)
|
static com.google.common.base.Optional<?> |
extractPathParam(RouteContext routeContext,
String paramName,
Class<?> type)
Extracts a path parameter from the passed in request path. |
private static Map<String,Object> |
extractRequestParam(String paramName,
Class<?> type,
com.google.common.base.Optional<?> defaultValue,
Map<String,Object> map,
RouteContext routeContext)
|
private static Map<String,Object> |
extractRequestParams(ReplacementParameter<?> replacementParam,
RouteContext routeContext)
|
private static Consumer |
getConsumer(RouteContext routeContext,
Map<String,Consumer> consumers,
Parameter<?> parameter)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IOGI
private static final br.com.caelum.iogi.Iogi IOGI
ParameterExtractor
public ParameterExtractor()
extractArguments
public static Map<String,Object> extractArguments(RouteContext routeContext,
Map<String,Consumer> consumers)
throws Exception
- Extracts the arguments from the current request for the target route.
- Parameters:
routeContext - the RouteContext.consumers - the Consumers that will be used to try to unmarshall the request body.
- Returns:
Map<String, Object containing parameter name -> value mapping.
- Throws:
Exception
extractRequestParam
private static Map<String,Object> extractRequestParam(String paramName,
Class<?> type,
com.google.common.base.Optional<?> defaultValue,
Map<String,Object> map,
RouteContext routeContext)
throws Exception
- Throws:
Exception
extractRequestParams
private static Map<String,Object> extractRequestParams(ReplacementParameter<?> replacementParam,
RouteContext routeContext)
throws Exception
- Throws:
Exception
extractDefaultParam
private static com.google.common.base.Optional<?> extractDefaultParam(Class<?> type,
com.google.common.base.Optional<?> defaultValue)
throws Exception
- Throws:
Exception
extractBody
private static Object extractBody(RouteContext routeContext,
Parameter<?> parameter,
Consumer consumer)
getConsumer
private static Consumer getConsumer(RouteContext routeContext,
Map<String,Consumer> consumers,
Parameter<?> parameter)
extractContentType
private static com.google.common.base.Optional<String> extractContentType(RouteContext routeContext)
extractPathParam
public static com.google.common.base.Optional<?> extractPathParam(RouteContext routeContext,
RequestParameter<?> param)
throws Exception
- Throws:
Exception
extractPathParam
public static com.google.common.base.Optional<?> extractPathParam(RouteContext routeContext,
String paramName,
Class<?> type)
throws Exception
- Extracts a path parameter from the passed in request path.
- Parameters:
routeContext - the RouteContext to extract a path parameter from.paramName - the name of the parameter to be extracted.type - the parameter type.
- Returns:
Optional<String> containing the extracted path param if present in the request path.
- Throws:
Exception
extractIogiParam
public static com.google.common.base.Optional<?> extractIogiParam(RouteContext routeContext)
- Returns an instance of the type used in the parameter names using Iogi. For example, having form parameters named
'car.color', 'car.brand', this method would try to use those values to instantiate a new Car instance.
- Returns:
Optional may contain the instantiated instance, else isPresent will return false.
addIfPresent
private static boolean addIfPresent(com.google.common.base.Optional<?> op,
String paramName,
Map<String,Object> args)
extractHeaderParam
private static com.google.common.base.Optional<?> extractHeaderParam(RouteContext routeContext,
String paramName)
extractCookieParam
private static com.google.common.base.Optional<?> extractCookieParam(RouteContext routeContext,
String paramName,
Class<?> type)
throws Exception
- Throws:
Exception
extractParam
private static com.google.common.base.Optional<?> extractParam(RouteContext routeContext,
String name,
Class<?> type)
throws Exception
- Throws:
Exception
createInstance
private static Object createInstance(Class<?> type,
String arg)
throws Exception
- Throws:
Exception
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.