org.mentawai.core
Class AbstractInput

java.lang.Object
  extended by org.mentawai.core.AbstractInput
All Implemented Interfaces:
Input
Direct Known Subclasses:
MapInput, RequestInput

public abstract class AbstractInput
extends Object
implements Input


Constructor Summary
AbstractInput()
           
 
Method Summary
 boolean getBoolean(String name)
          Calls getStringValue() and tries to convert the string to boolean.
 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)
          Calls getString() and tries to convert the string to a double.
 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 key, Class<E> enumClass)
          Convert the parameter value from this action input as an Enum.
<E extends Enum<E>>
Set<E>
getEnums(String key, Class<E> enumClass)
          Convert the parameter value from this action input as an Array of Enums.
 float getFloat(String name)
          Calls getString() and tries to convert the string to a float.
 float getFloat(String name, float def)
           
 float getFloatValue(String name)
          Deprecated. use getFloat instead
 float getFloatValue(String name, float def)
          Deprecated. use getFloat instead
 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
protected abstract  Locale getLocale()
           
 long getLong(String name)
          Calls getString() and tries to convert the string to a long.
 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, boolean convertBoolean)
           
<E> E
getObject(Class<? extends E> klass, String prefix)
          Gets a populated object with the values from the action input.
<E> E
getObject(Class<? extends E> klass, String prefix, boolean convertBoolean)
           
<E> E
getObject(E bean, boolean convertBoolean)
           
<E> E
getObject(E bean, String prefix, boolean convertBoolean)
           
<E> E
getObject(E target, String prefix, boolean tryField, boolean tryToConvert, boolean convertBoolean)
           
 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.
static boolean isB()
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mentawai.core.Input
getHeader, getHeaderKeys, getProperty, getString, getStrings, getStringValue, getStringValues, getValue, has, hasValue, keys, removeValue, setValue
 

Constructor Detail

AbstractInput

public AbstractInput()
Method Detail

getBoolean

public boolean getBoolean(String name)
Calls getStringValue() and tries to convert the string to boolean.

Specified by:
getBoolean 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,
                          boolean def)
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

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

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

getLocale

protected abstract Locale getLocale()

getDouble

public double getDouble(String name)
Calls getString() and tries to convert the string to a double.

Specified by:
getDouble 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,
                        double def)
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

getFloat

public float getFloat(String name)
Calls getString() and tries to convert the string to a float.

Specified by:
getFloat 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,
                      float def)
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

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

getInts

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

getIntValues

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

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.

getLong

public long getLong(String name)
Calls getString() and tries to convert the string to a long.

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)
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,
                    long def)
Specified by:
getLong in interface Input

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

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,
                       boolean convertBoolean)

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

getObject

public <E> E getObject(Class<? extends E> klass,
                       String prefix,
                       boolean convertBoolean)

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

getObject

public <E> E getObject(E bean,
                       boolean convertBoolean)

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

getObject

public <E> E getObject(E bean,
                       String prefix,
                       boolean convertBoolean)

getObject

public <E> E getObject(E target,
                       String prefix,
                       boolean tryField,
                       boolean tryToConvert,
                       boolean convertBoolean)

getEnum

public <E extends Enum<E>> E getEnum(String key,
                                     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:
key - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration

getEnums

public <E extends Enum<E>> Set<E> getEnums(String key,
                                           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:
key - the parameter's name
enumClass - the Enum's class
Returns:
Return the Enumeration

isB

public static boolean isB()

main

public static void main(String[] args)


Copyright © 2013. All Rights Reserved.