org.mentawai.core
Class RequestInput

java.lang.Object
  extended by org.mentawai.core.AbstractInput
      extended by org.mentawai.core.RequestInput
All Implemented Interfaces:
Map<String,Object>, Input
Direct Known Subclasses:
PrettyURLRequestInput

public class RequestInput
extends AbstractInput
implements Map<String,Object>

Encapsulates a HttpServletRequest as an Input for Mentawai actions. This class also implements the java.util.Map interface so it can be used with JSP Expression Language. Most of map operations are not supported.

Version:
$Id: InputRequest.java,v 1.1 2006/03/02 17:11:36 soliveira Exp $
Author:
Sergio Oliveira

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected static Map<String,Method> cache
           
protected  Set<String> keys
           
protected  Map<String,Object> map
           
protected  javax.servlet.http.HttpServletRequest req
           
protected  javax.servlet.http.HttpServletResponse res
           
 
Constructor Summary
RequestInput(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Creates an Input for the given HttpServletRequest.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<String,Object>> entrySet()
           
 Object get(Object key)
           
 String getHeader(String name)
          Gets a header value from this input.
 Iterator<String> getHeaderKeys()
          Gets an iterator with all header names.
protected  Locale getLocale()
           
 String getProperty(String name)
          Gets a property associated with this input.
 javax.servlet.http.HttpServletRequest getRequest()
          Gets the HttpServletRequest this input encapsulates.
 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.
 boolean isEmpty()
           
 Iterator<String> keys()
          Gets an iterator with all the parameter names.
 Set<String> keySet()
           
 Object put(String key, Object value)
           
 void putAll(Map<? extends String,? extends Object> t)
           
 Object remove(Object key)
           
 void removeValue(String name)
          Removes a parameter from this input.
 void setValue(String name, Object value)
          Sets a parameter value with the given name.
 int size()
           
 String toString()
           
 Collection<Object> values()
           
 
Methods inherited from class org.mentawai.core.AbstractInput
getBoolean, getBoolean, getBooleanValue, getBooleanValue, getDate, getDate, getDate, getDouble, getDouble, getDoubleValue, getDoubleValue, getEnum, getEnums, getFloat, getFloat, getFloatValue, getFloatValue, getInt, getInt, getInts, getIntValue, getIntValue, getIntValues, getLong, getLong, getLongs, getLongValue, getLongValue, getObject, getObject, getObject, getObject, getObject, getObject, getObject, inject, inject, isB, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected Map<String,Object> map

req

protected javax.servlet.http.HttpServletRequest req

res

protected javax.servlet.http.HttpServletResponse res

cache

protected static Map<String,Method> cache

keys

protected Set<String> keys
Constructor Detail

RequestInput

public RequestInput(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
Creates an Input for the given HttpServletRequest.

Parameters:
req - The request
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Gets the HttpServletRequest this input encapsulates.

Returns:
The request this input encapsulates

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

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

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

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.

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.

getStringValue

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

If the parameter is not a String, its 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

getStringValues

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

If the parameter is not a String or a String array, a InputException will be thrown. If the parameter is a String, a String array of size one with the string is returned.

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

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)

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

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.

clear

public void clear()
Specified by:
clear in interface Map<String,Object>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<String,Object>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,Object>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<String,Object>

get

public Object get(Object key)
Specified by:
get in interface Map<String,Object>

keySet

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

put

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

putAll

public void putAll(Map<? extends String,? extends Object> t)
Specified by:
putAll in interface Map<String,Object>

remove

public Object remove(Object key)
Specified by:
remove in interface Map<String,Object>

size

public int size()
Specified by:
size in interface Map<String,Object>

values

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

entrySet

public Set<Map.Entry<String,Object>> entrySet()
Specified by:
entrySet in interface Map<String,Object>

getLocale

protected Locale getLocale()
Specified by:
getLocale in class AbstractInput


Copyright © 2013. All Rights Reserved.