org.mentawai.core
Interface Input

All Known Implementing Classes:
AbstractInput, ActionContextFilter, ApplicationFilter, AutoWiringFilter, ConnectionFilter, CookiesFilter, DIFilter, ErrorsFilter, FieldErrorsFilter, HeadersFilter, HibernateAnnotationFilter, HibernateFilter, InputWrapper, IoCFilter, JpaFilter, MapInput, MentaContainerFilter, MessagesFilter, OutputFilter, PostOrGetFilter, PrettyURLRequestInput, RequestInput, SessionFilter, SpringInput

public interface Input

Defines the behavior of an action input. An Input has parameters and headers. Parameters can be any java object, and not only strings. Headers can be only strings. Parameters are not read-only, and actions and filters can modify it, if they need to. Headers are read-only.

Author:
Sergio Oliveira

Method Summary
 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 instead.
 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. getLong instead
 long getLongValue(String name, long def)
          Deprecated. 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.
 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.
 Iterator<String> keys()
          Gets an iterator with all the parameter names.
 void removeValue(String name)
          Removes a parameter from this input.
 void setValue(String name, Object value)
          Sets a parameter value with the given name.
 

Method Detail

getHeader

String getHeader(String name)
Gets a header value from this input.

Parameters:
name - the header name
Returns:
the header value

getHeaderKeys

Iterator<String> getHeaderKeys()
Gets an iterator with all header names.

Returns:
an iterator with all header names

hasValue

boolean hasValue(String name)
Checks if a value exists.

Parameters:
name - The name of the key.
Returns:
true if exists
Since:
1.11

has

boolean has(String key)
Check if the input has this key (Shorter verions of hasValue)

Parameters:
key -
Since:
2.0.1

getProperty

String getProperty(String name)
Gets a property associated with this input.

Parameters:
name - the name of the property
Returns:
the value of the property as a String

getStringValue

String getStringValue(String name)
Deprecated. Use getString instead

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

Parameters:
name - the parameter's name
Returns:
the parameter's value as a string or null if it doesn't exist

getString

String getString(String name)

getIntValue

int getIntValue(String name)
Deprecated. Use getInt instead

Gets a parameter value from this input as an int.

Parameters:
name - the parameter's name
Returns:
the parameters's value as an int
Throws:
NullPointerException - if the value does not exist.
InputException - is the value cannot be converted to an int.

getInt

int getInt(String name)

getStringValues

String[] getStringValues(String name)
Deprecated. Use getStrings instead

Gets all parameter values with the given name as a string array.

Parameters:
name - the parameters'name
Returns:
a string array with all the values or null if they don't exist.

getStrings

String[] getStrings(String name)

getIntValues

int[] getIntValues(String name)
Deprecated. Use getInts instead.

Gets all parameter values with the given name as an int array.

Parameters:
name - the parameters'name
Returns:
a int array with all the values or null if the don't exist.
Throws:
InputException - if any of the values cannot be converted to an int.

getInts

int[] getInts(String name)

setValue

void setValue(String name,
              Object value)
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.

Parameters:
name - the name of the parameter
value - the parameter value (any object)

getValue

Object getValue(String name)
Gets a parameter value (any object) with the given name.

Parameters:
name - the name of the parameter
Returns:
the parameter value (any object) or null if it doesn't exist.

removeValue

void removeValue(String name)
Removes a parameter from this input.

Parameters:
name - the name of the parameter to remove.

keys

Iterator<String> keys()
Gets an iterator with all the parameter names.

Returns:
an iterator with all the parameter names.

getIntValue

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

Gets a parameter value from this input as an int.

Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as an int or def if not found
Throws:
InputException - is the value cannot be converted to an int.

getInt

int getInt(String name,
           int def)

getLongValue

long getLongValue(String name)
Deprecated. getLong instead

Gets a parameter value from this input as a long.

Parameters:
name - the parameter's name
Returns:
the parameters's value as a long
Throws:
NullPointerException - if the value does not exist.
InputException - is the value cannot be converted to a long

getLong

long getLong(String name)

getLongs

long[] getLongs(String name)
Gets all parameter values with the given name as an long array.

Parameters:
name - the parameters'name
Returns:
a long array with all the values or null if the don't exist.
Throws:
InputException - if any of the values cannot be converted to an long.

getLongValue

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

Gets a parameter value from this input as a long.

Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a long or def if not found
Throws:
InputException - is the value cannot be converted to a long.

getLong

long getLong(String name,
             long def)

getBooleanValue

boolean getBooleanValue(String name)
Deprecated. use getBoolean instead

Gets a parameter value from this input as a boolean.

Parameters:
name - the parameter's name
Returns:
the parameters's value as a boolean
Throws:
NullPointerException - if the value does not exist.
InputException - is the value cannot be converted to a boolean.

getBoolean

boolean getBoolean(String name)

getBooleanValue

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

Gets a parameter value from this input as a boolean.

Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a boolean or def if not found
Throws:
InputException - is the value cannot be converted to a boolean.

getBoolean

boolean getBoolean(String name,
                   boolean def)

getFloatValue

float getFloatValue(String name)
Deprecated. use getFloat instead

Gets a parameter value from this input as a float.

Parameters:
name - the parameter's name
Returns:
the parameters's value as a float
Throws:
NullPointerException - if the value does not exist.
InputException - is the value cannot be converted to a float.

getFloat

float getFloat(String name)

getFloatValue

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

Gets a parameter value from this input as a float.

Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a float or def if not found
Throws:
InputException - is the value cannot be converted to a float.

getFloat

float getFloat(String name,
               float def)

getDoubleValue

double getDoubleValue(String name)
Deprecated. use getDouble instead

Gets a parameter value from this input as a double.

Parameters:
name - the parameter's name
Returns:
the parameters's value as a double
Throws:
NullPointerException - if the value does not exist.
InputException - is the value cannot be converted to a double

getDouble

double getDouble(String name)

getDoubleValue

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

Gets a parameter value from this input as a double.

Parameters:
name - the parameter's name
def - default value to return
Returns:
the parameters's value as a double or def if not found
Throws:
InputException - is the value cannot be converted to a double.

getDouble

double getDouble(String name,
                 double def)

getObject

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

Parameters:
klass -
Returns:
The populated object
Since:
1.8

inject

void inject(Object bean)
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.

Parameters:
bean -
Since:
2.2.3

getObject

<E> E getObject(Class<? extends E> klass,
                String prefix)
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!

Parameters:
klass -
prefix -
Returns:
The populated object
Since:
1.8

inject

void inject(Object bean,
            String prefix)
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.

Parameters:
bean -
prefix -
Since:
2.2.3

getDate

Date getDate(String name)
Parse a parameter value from this input as a Date.

Parameters:
name - the parameter's name
Returns:
the parameter's value as a Date or null if it doesn't exist
Throws:
InputException - throws if the attributte can't be parsed

getDate

Date getDate(String name,
             int style)
Parse a parameter value from this action input as a Date using the given style.

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
Throws:
InputException - throws if the attributte can't be parsed

getDate

Date getDate(String name,
             String pattern)
Parse a parameter value from this action input as a Date using the given pattern.

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
Throws:
InputException - throws if the attributte can't be parsed

getEnum

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

Parameters:
name - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration

getEnums

<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.

Parameters:
name - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration


Copyright © 2013. All Rights Reserved.