org.mentawai.core
Class RequestInput

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

public class RequestInput
extends AbstractInput
implements java.util.Map<java.lang.String,java.lang.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
java.util.Map.Entry<K,V>
 
Field Summary
protected static java.util.Map<java.lang.String,java.lang.reflect.Method> cache
           
protected  java.util.Set<java.lang.String> keys
           
protected  java.util.Map<java.lang.String,java.lang.Object> map
           
protected  javax.servlet.http.HttpServletRequest req
           
 
Fields inherited from interface org.mentawai.core.Input
DEFAULT_CHARSET
 
Constructor Summary
RequestInput(javax.servlet.http.HttpServletRequest req)
          Creates an Input for the given HttpServletRequest.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.String getHeader(java.lang.String name)
          Gets a header value from this input.
 java.util.Iterator<java.lang.String> getHeaderKeys()
          Gets an iterator with all header names.
protected  java.util.Locale getLocale()
           
 java.lang.String getProperty(java.lang.String name)
          Gets a property associated with this input.
 javax.servlet.http.HttpServletRequest getRequest()
          Gets the HttpServletRequest this input encapsulates.
 java.lang.String getString(java.lang.String name)
           
 java.lang.String[] getStrings(java.lang.String name)
           
 java.lang.String getStringValue(java.lang.String name)
          Deprecated. use getString instead
 java.lang.String[] getStringValues(java.lang.String name)
          Deprecated. use getStrings instead
 java.lang.Object getValue(java.lang.String name)
          Gets a parameter value (any object) with the given name.
 boolean hasValue(java.lang.String name)
          Checks if a value exists.
 boolean isEmpty()
           
 java.util.Iterator<java.lang.String> keys()
          Gets an iterator with all the parameter names.
 java.util.Set<java.lang.String> keySet()
           
 java.lang.Object put(java.lang.String key, java.lang.Object value)
           
 void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> t)
           
 java.lang.Object remove(java.lang.Object key)
           
 void removeValue(java.lang.String name)
          Removes a parameter from this input.
 void setValue(java.lang.String name, java.lang.Object value)
          Sets a parameter value with the given name.
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<java.lang.Object> values()
           
 
Methods inherited from class org.mentawai.core.AbstractInput
getBoolean, getBoolean, getBooleanValue, getBooleanValue, getDate, getDate, getDate, getDouble, getDouble, getDoubleValue, getDoubleValue, getEnum, getFloat, getFloat, getFloatValue, getFloatValue, getInt, getInt, getInts, getIntValue, getIntValue, getIntValues, getLong, getLong, getLongValue, getLongValue, getObject, getObject, getObject, getObject, getObject
 
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 java.util.Map<java.lang.String,java.lang.Object> map

req

protected javax.servlet.http.HttpServletRequest req

cache

protected static java.util.Map<java.lang.String,java.lang.reflect.Method> cache

keys

protected java.util.Set<java.lang.String> keys
Constructor Detail

RequestInput

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

Parameters:
req - The request
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRequest

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

Returns:
The request this input encapsulates

getProperty

public java.lang.String getProperty(java.lang.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 java.lang.String getHeader(java.lang.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 java.util.Iterator<java.lang.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 java.util.Iterator<java.lang.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(java.lang.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 java.lang.String getStringValue(java.lang.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 java.lang.String getString(java.lang.String name)
Specified by:
getString in interface Input

getStringValues

public java.lang.String[] getStringValues(java.lang.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 java.lang.String[] getStrings(java.lang.String name)
Specified by:
getStrings in interface Input

setValue

public void setValue(java.lang.String name,
                     java.lang.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(java.lang.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

getValue

public java.lang.Object getValue(java.lang.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 java.util.Map<java.lang.String,java.lang.Object>

isEmpty

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

containsKey

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

containsValue

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

get

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

keySet

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

put

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

putAll

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

remove

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

size

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

values

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

entrySet

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

getLocale

protected java.util.Locale getLocale()
Specified by:
getLocale in class AbstractInput


Copyright © 2005 Mentawai Team. All Rights Reserved.