net.craftforge.essential.controller.managers
Class ParameterHandler

java.lang.Object
  extended by net.craftforge.essential.controller.managers.ParameterHandler

public class ParameterHandler
extends Object

Since:
21.08.11
Author:
Christian Bick

Constructor Summary
ParameterHandler(Map<String,String[]> parameters)
           
 
Method Summary
protected  Object convertToObject(Consumer consumer, Class<?> type, String parameterValue)
           
protected  ControllerException getMissingParameterException(String paramName)
           
 String getParameterValue(String parameterName, String[] defaultValues)
           
 Object getParameterValueAsObject(Consumer consumer, Class<?> type, String parameterName, String[] defaultValues)
           
 String[] getParameterValues(String parameterName, String[] defaultValues)
           
<G> Collection<G>
getParameterValuesAsObject(Consumer consumer, Class<?> collectionType, Class<G> typeArgument, String parameterName, String[] defaultValues)
          Gets the input for a collection type using the generic type as deserialization hint for the parameter values associated to the given parameter name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterHandler

public ParameterHandler(Map<String,String[]> parameters)
Method Detail

getParameterValues

public String[] getParameterValues(String parameterName,
                                   String[] defaultValues)
                            throws ControllerException
Throws:
ControllerException

getParameterValue

public String getParameterValue(String parameterName,
                                String[] defaultValues)
                         throws ControllerException
Throws:
ControllerException

getParameterValueAsObject

public Object getParameterValueAsObject(Consumer consumer,
                                        Class<?> type,
                                        String parameterName,
                                        String[] defaultValues)
                                 throws ControllerException
Throws:
ControllerException

getParameterValuesAsObject

public <G> Collection<G> getParameterValuesAsObject(Consumer consumer,
                                                    Class<?> collectionType,
                                                    Class<G> typeArgument,
                                                    String parameterName,
                                                    String[] defaultValues)
                                         throws ControllerException
Gets the input for a collection type using the generic type as deserialization hint for the parameter values associated to the given parameter name.

Type Parameters:
G - The generic type parameter
Parameters:
consumer - The consumer
collectionType - The collection type
typeArgument - The collection's generic type argument
parameterName - The parameter name
defaultValues - The default values to use if no parameter values are given
Returns:
The collection initialized from the parameter values
Throws:
ControllerException - Failed to initialize the collection

convertToObject

protected Object convertToObject(Consumer consumer,
                                 Class<?> type,
                                 String parameterValue)
                          throws ControllerException
Throws:
ControllerException

getMissingParameterException

protected ControllerException getMissingParameterException(String paramName)


Copyright © 2011. All Rights Reserved.