org.mentawai.core
Class InputWrapper

java.lang.Object
  extended by org.mentawai.core.InputWrapper
All Implemented Interfaces:
Map, Input
Direct Known Subclasses:
ActionContextFilter, ApplicationFilter, AutoWiringFilter, ConnectionFilter, CookiesFilter, DIFilter, ErrorsFilter, FieldErrorsFilter, HeadersFilter, HibernateFilter, IoCFilter, JpaFilter, MentaContainerFilter, MessagesFilter, OutputFilter, PostOrGetFilter, SessionFilter, SpringInput

public class InputWrapper
extends Object
implements Input, Map

A wrapper for the action input.

Author:
Davi Luan Carneiro

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
InputWrapper()
           
InputWrapper(Input input)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Iterator entries()
           
 Set entrySet()
           
 Object get(Object key)
           
 boolean getBoolean(String name)
           
 boolean getBoolean(String name, boolean def)
           
 boolean getBooleanValue(String name)
          Deprecated. use getBoolean instead
 boolean getBooleanValue(String name, boolean def)
          Deprecated. use getBoolean instead
 Date getDate(String name)
          Parse a parameter value from this input as a Date.
 Date getDate(String name, int style)
          Parse a parameter value from this action input as a Date using the given style.
 Date getDate(String name, String pattern)
          Parse a parameter value from this action input as a Date using the given pattern.
 double getDouble(String name)
           
 double getDouble(String name, double def)
           
 double getDoubleValue(String name)
          Deprecated. use getDouble instead
 double getDoubleValue(String name, double def)
          Deprecated. use getDouble instead
<E extends Enum<E>>
E
getEnum(String name, Class<E> enumClass)
          Convert the parameter value from this action input as an Enum.
<E extends Enum<E>>
Set<E>
getEnums(String name, Class<E> enumClass)
          Convert the parameter value from this action input as an Array of Enums.
 float getFloat(String name)
           
 float getFloat(String name, float def)
           
 float getFloatValue(String name)
          Deprecated. use getFloat instead
 float getFloatValue(String name, float def)
          Deprecated. use getFloat instead
 String getHeader(String name)
          Gets a header value from this input.
 Iterator<String> getHeaderKeys()
          Gets an iterator with all header names.
 int getInt(String name)
           
 int getInt(String name, int def)
           
 int[] getInts(String name)
           
 int getIntValue(String name)
          Deprecated. use getInt instead
 int getIntValue(String name, int def)
          Deprecated. use getInt instead
 int[] getIntValues(String name)
          Deprecated. use getInts intead
 long getLong(String name)
           
 long getLong(String name, long def)
           
 long[] getLongs(String name)
          Gets all parameter values with the given name as an long array.
 long getLongValue(String name)
          Deprecated. use getLong instead
 long getLongValue(String name, long def)
          Deprecated. use getLong instead
<E> E
getObject(Class<? extends E> klass)
          Gets a populated object with the values from the action input.
<E> E
getObject(Class<? extends E> klass, String prefix)
          Gets a populated object with the values from the action input.
 String getProperty(String name)
          Gets a property associated with this input.
 Input getRoot()
           
 String getString(String name)
           
 String[] getStrings(String name)
           
 String getStringValue(String name)
          Deprecated. use getString instead
 String[] getStringValues(String name)
          Deprecated. use getStrings instead
 Object getValue(String name)
          Gets a parameter value (any object) with the given name.
 boolean has(String key)
          Check if the input has this key (Shorter verions of hasValue)
 boolean hasValue(String name)
          Checks if a value exists.
 void inject(Object bean)
          Populates (inject properties) the bean with the values from the input.
 void inject(Object bean, String prefix)
          Populates (inject properties) the bean with the values from the input.
 boolean isEmpty()
           
 Iterator<String> keys()
          Gets an iterator with all the parameter names.
 Set<Object> keySet()
           
 Object put(Object key, Object value)
           
 void putAll(Map map)
           
 Object remove(Object key)
           
 void removeInput()
           
 void removeValue(String name)
          Removes a parameter from this input.
 void setInput(Input input)
           
 void setValue(String name, Object value)
          Sets a parameter value with the given name.
 int size()
           
 Collection<Object> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

InputWrapper

public InputWrapper()

InputWrapper

public InputWrapper(Input input)
Method Detail

setInput

public void setInput(Input input)

getRoot

public Input getRoot()

removeInput

public void removeInput()

getHeader

public String getHeader(String name)
Description copied from interface: Input
Gets a header value from this input.

Specified by:
getHeader in interface Input
Parameters:
name - the header name
Returns:
the header value

getStringValue

public String getStringValue(String name)
Deprecated. use getString instead

Description copied from interface: Input
Gets a parameter value from this input as a String. If this object is not a String, the toString() method is called.

Specified by:
getStringValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameter's value as a string or null if it doesn't exist

getString

public String getString(String name)
Specified by:
getString in interface Input

getIntValue

public int getIntValue(String name)
Deprecated. use getInt instead

Description copied from interface: Input
Gets a parameter value from this input as an int.

Specified by:
getIntValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameters's value as an int

getInt

public int getInt(String name)
Specified by:
getInt in interface Input

getIntValue

public int getIntValue(String name,
                       int def)
Deprecated. use getInt instead

Description copied from interface: Input
Gets a parameter value from this input as an int.

Specified by:
getIntValue in interface Input
Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as an int or def if not found

getInt

public int getInt(String name,
                  int def)
Specified by:
getInt in interface Input

hasValue

public boolean hasValue(String name)
Description copied from interface: Input
Checks if a value exists.

Specified by:
hasValue in interface Input
Parameters:
name - The name of the key.
Returns:
true if exists

has

public boolean has(String key)
Description copied from interface: Input
Check if the input has this key (Shorter verions of hasValue)

Specified by:
has in interface Input

getLongValue

public long getLongValue(String name)
Deprecated. use getLong instead

Description copied from interface: Input
Gets a parameter value from this input as a long.

Specified by:
getLongValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameters's value as a long

getLong

public long getLong(String name)
Specified by:
getLong in interface Input

getLongs

public long[] getLongs(String name)
Description copied from interface: Input
Gets all parameter values with the given name as an long array.

Specified by:
getLongs in interface Input
Parameters:
name - the parameters'name
Returns:
a long array with all the values or null if the don't exist.

getLongValue

public long getLongValue(String name,
                         long def)
Deprecated. use getLong instead

Description copied from interface: Input
Gets a parameter value from this input as a long.

Specified by:
getLongValue in interface Input
Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a long or def if not found

getLong

public long getLong(String name,
                    long def)
Specified by:
getLong in interface Input

getFloatValue

public float getFloatValue(String name)
Deprecated. use getFloat instead

Description copied from interface: Input
Gets a parameter value from this input as a float.

Specified by:
getFloatValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameters's value as a float

getFloat

public float getFloat(String name)
Specified by:
getFloat in interface Input

getFloatValue

public float getFloatValue(String name,
                           float def)
Deprecated. use getFloat instead

Description copied from interface: Input
Gets a parameter value from this input as a float.

Specified by:
getFloatValue in interface Input
Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a float or def if not found

getFloat

public float getFloat(String name,
                      float def)
Specified by:
getFloat in interface Input

getDoubleValue

public double getDoubleValue(String name)
Deprecated. use getDouble instead

Description copied from interface: Input
Gets a parameter value from this input as a double.

Specified by:
getDoubleValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameters's value as a double

getDouble

public double getDouble(String name)
Specified by:
getDouble in interface Input

getDoubleValue

public double getDoubleValue(String name,
                             double def)
Deprecated. use getDouble instead

Description copied from interface: Input
Gets a parameter value from this input as a double.

Specified by:
getDoubleValue in interface Input
Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a double or def if not found

getDouble

public double getDouble(String name,
                        double def)
Specified by:
getDouble in interface Input

getBooleanValue

public boolean getBooleanValue(String name)
Deprecated. use getBoolean instead

Description copied from interface: Input
Gets a parameter value from this input as a boolean.

Specified by:
getBooleanValue in interface Input
Parameters:
name - the parameter's name
Returns:
the parameters's value as a boolean

getBoolean

public boolean getBoolean(String name)
Specified by:
getBoolean in interface Input

getBooleanValue

public boolean getBooleanValue(String name,
                               boolean def)
Deprecated. use getBoolean instead

Description copied from interface: Input
Gets a parameter value from this input as a boolean.

Specified by:
getBooleanValue in interface Input
Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a boolean or def if not found

getBoolean

public boolean getBoolean(String name,
                          boolean def)
Specified by:
getBoolean in interface Input

getStringValues

public String[] getStringValues(String name)
Deprecated. use getStrings instead

Description copied from interface: Input
Gets all parameter values with the given name as a string array.

Specified by:
getStringValues in interface Input
Parameters:
name - the parameters'name
Returns:
a string array with all the values or null if they don't exist.

getStrings

public String[] getStrings(String name)
Specified by:
getStrings in interface Input

getIntValues

public int[] getIntValues(String name)
Deprecated. use getInts intead

Description copied from interface: Input
Gets all parameter values with the given name as an int array.

Specified by:
getIntValues in interface Input
Parameters:
name - the parameters'name
Returns:
a int array with all the values or null if the don't exist.

getInts

public int[] getInts(String name)
Specified by:
getInts in interface Input

setValue

public void setValue(String name,
                     Object value)
Description copied from interface: Input
Sets a parameter value with the given name. The parameter can be any object. If the parameter already exists the old value is substituted by the new one.

Specified by:
setValue in interface Input
Parameters:
name - the name of the parameter
value - the parameter value (any object)

getValue

public Object getValue(String name)
Description copied from interface: Input
Gets a parameter value (any object) with the given name.

Specified by:
getValue in interface Input
Parameters:
name - the name of the parameter
Returns:
the parameter value (any object) or null if it doesn't exist.

removeValue

public void removeValue(String name)
Description copied from interface: Input
Removes a parameter from this input.

Specified by:
removeValue in interface Input
Parameters:
name - the name of the parameter to remove.

keys

public Iterator<String> keys()
Description copied from interface: Input
Gets an iterator with all the parameter names.

Specified by:
keys in interface Input
Returns:
an iterator with all the parameter names.

getHeaderKeys

public Iterator<String> getHeaderKeys()
Description copied from interface: Input
Gets an iterator with all header names.

Specified by:
getHeaderKeys in interface Input
Returns:
an iterator with all header names

getProperty

public String getProperty(String name)
Description copied from interface: Input
Gets a property associated with this input.

Specified by:
getProperty in interface Input
Parameters:
name - the name of the property
Returns:
the value of the property as a String

getObject

public <E> E getObject(Class<? extends E> klass)
Description copied from interface: Input
Gets a populated object with the values from the action input. OBS: Excelent idea given by Bruno Braga!

Specified by:
getObject in interface Input
Returns:
The populated object

getObject

public <E> E getObject(Class<? extends E> klass,
                       String prefix)
Description copied from interface: Input
Gets a populated object with the values from the action input. Use the prefix in front of every value name. OBS: Excelent idea given by Bruno Braga!

Specified by:
getObject in interface Input
Returns:
The populated object

inject

public void inject(Object bean)
Description copied from interface: Input
Populates (inject properties) the bean with the values from the input. Any property already set in the bean is overwritten. If you have a property in the bean but not in the input, this property is not changed.

Specified by:
inject in interface Input

inject

public void inject(Object bean,
                   String prefix)
Description copied from interface: Input
Populates (inject properties) the bean with the values from the input. Any property already set in the bean is overwritten. If you have a property in the bean but not in the input, this property is not changed. Use the prefix in front of every key when getting the values from the input.

Specified by:
inject in interface Input

clear

public void clear()
Specified by:
clear in interface Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

keySet

public Set<Object> keySet()
Specified by:
keySet in interface Map

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map

putAll

public void putAll(Map map)
Specified by:
putAll in interface Map

remove

public Object remove(Object key)
Specified by:
remove in interface Map

size

public int size()
Specified by:
size in interface Map

values

public Collection<Object> values()
Specified by:
values in interface Map

entries

public Iterator entries()

getDate

public Date getDate(String name)
Description copied from interface: Input
Parse a parameter value from this input as a Date.

Specified by:
getDate in interface Input
Parameters:
name - the parameter's name
Returns:
the parameter's value as a Date or null if it doesn't exist

getDate

public Date getDate(String name,
                    String pattern)
Description copied from interface: Input
Parse a parameter value from this action input as a Date using the given pattern.

Specified by:
getDate in interface Input
Parameters:
name - the parameter's name
pattern - The SimpleDateFormat pattern to be used
Returns:
the parameter's value as a Date or null if it doesn't exist

getDate

public Date getDate(String name,
                    int style)
Description copied from interface: Input
Parse a parameter value from this action input as a Date using the given style.

Specified by:
getDate in interface Input
Parameters:
name - the parameter's name
style - the DateFormat style to be used
Returns:
the parameter's value as a Date or null if it doesn't exist

getEnum

public <E extends Enum<E>> E getEnum(String name,
                                     Class<E> enumClass)
Description copied from interface: Input
Convert the parameter value from this action input as an Enum.

Specified by:
getEnum in interface Input
Parameters:
name - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration

getEnums

public <E extends Enum<E>> Set<E> getEnums(String name,
                                           Class<E> enumClass)
Description copied from interface: Input
Convert the parameter value from this action input as an Array of Enums.

Specified by:
getEnums in interface Input
Parameters:
name - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration


Copyright © 2013. All Rights Reserved.