public abstract class AbstractValueParser extends Object implements ValueParser
注意:参数和cookie的名称可能被转换成全部大写或全部小写。 这是根据配置文件中的参数:caseFolding 来指定的。
| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.beans.SimpleTypeConverter |
converter |
protected static Logger |
logger |
protected Map<String,String> |
parameterKeys |
protected Map<String,Object> |
parameters |
protected ParserWebContext |
webContext |
| Constructor and Description |
|---|
AbstractValueParser(ParserWebContext requestContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String key,
boolean value)
添加参数名/参数值。
|
void |
add(String key,
byte value)
添加参数名/参数值。
|
void |
add(String key,
char value)
添加参数名/参数值。
|
void |
add(String key,
double value)
添加参数名/参数值。
|
void |
add(String key,
float value)
添加参数名/参数值。
|
void |
add(String key,
int value)
添加参数名/参数值。
|
void |
add(String key,
long value)
添加参数名/参数值。
|
void |
add(String key,
Object value)
添加参数名/参数值。
|
void |
add(String key,
short value)
添加参数名/参数值。
|
void |
clear()
清除所有值。
|
boolean |
containsKey(String key)
检查是否包含指定名称的参数。
|
protected String |
convert(String key)
首先将参数名进行
trim(),然后再进行大小写转换。转换是根据配置文件中的
url.case.folding来设定的。 |
Object |
get(String key)
取得参数值,如果指定名称的参数不存在,则返回
null。 此方法和getObject
一样,但在模板中便易于使用。 |
boolean |
getBoolean(String key)
取得参数值,如果指定名称的参数不存在,则返回
false。 |
boolean |
getBoolean(String key,
boolean defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
byte |
getByte(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
byte |
getByte(String key,
byte defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
byte[] |
getBytes(String key)
取得指定参数的字节。这个字节是根据
getCharacterEncoding()所返回的字符集进行编码的。 |
char |
getChar(String key)
取得参数值,如果指定名称的参数不存在,则返回
'\0'。 |
char |
getChar(String key,
char defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
protected String |
getCharacterEncoding()
取得用于解析参数的编码字符集。不同的实现取得编码字符集的方法也不同,例如,对于
ParameterParser,
此编码字符集是由request.getCharacterEncoding()决定的。 |
Date |
getDate(String key,
DateFormat format)
取得日期。字符串将使用指定的
DateFormat来解析。如果不存在,则返回null。 |
Date |
getDate(String key,
DateFormat format,
Date defaultValue)
取得日期。字符串将使用指定的
DateFormat来解析。如果不存在,则返回默认值。 |
double |
getDouble(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
double |
getDouble(String key,
double defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
float |
getFloat(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
float |
getFloat(String key,
float defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
int |
getInt(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
int |
getInt(String key,
int defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
int[] |
getInts(String key)
取得指定参数的所有值。如果参数不存在,则返回
null。 |
int[] |
getInts(String key,
int[] defaultValue)
取得指定参数的所有值。如果参数不存在,则返回指定默认值。
|
String[] |
getKeys() |
long |
getLong(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
long |
getLong(String key,
long defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
long[] |
getLongs(String key)
取得指定参数的所有值。如果参数不存在,则返回
null。 |
long[] |
getLongs(String key,
long[] defaultValue)
取得指定参数的所有值。如果参数不存在,则返回指定默认值。
|
Object |
getObject(String key)
取得指定参数的值。如果参数不存在,则返回
null。 |
Object |
getObject(String key,
Object defaultValue)
取得指定参数的值。如果参数不存在,则返回默认值。
|
<T> T |
getObjectOfType(String key,
Class<T> type)
取得指定类型的对象。
|
<T> T |
getObjectOfType(String key,
Class<T> type,
org.springframework.core.MethodParameter methodParameter,
Object[] defaultValues)
取得指定类型的对象。
|
Object[] |
getObjects(String key)
取得指定参数的所有值。如果参数不存在,则返回
null。 |
Object[] |
getObjects(String key,
Object[] defaultValue)
取得指定参数的所有值。如果参数不存在,则返回指定默认值。
|
short |
getShort(String key)
取得参数值,如果指定名称的参数不存在,则返回
0。 |
short |
getShort(String key,
short defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
String |
getString(String key)
取得参数值,如果指定名称的参数不存在,则返回
null。 |
String |
getString(String key,
String defaultValue)
取得参数值,如果指定名称的参数不存在,则返回指定默认值。
|
String[] |
getStrings(String key)
取得指定参数的所有值。如果参数不存在,则返回
null。 |
String[] |
getStrings(String key,
String[] defaultValue)
取得指定参数的所有值。如果参数不存在,则返回指定默认值。
|
org.springframework.beans.TypeConverter |
getTypeConverter()
取得类型转换器。
|
protected ValueList |
getValueList(String key,
boolean create)
取得指定参数的值的列表。
|
boolean |
isEmpty()
判断是否无值。
|
Set<String> |
keySet() |
Object |
remove(String key)
删除指定名称的参数。
|
void |
remove(String key,
Object value)
添加参数名/参数值。
|
void |
setObject(String key,
Object value)
设置参数值。和
add方法不同,此方法将覆盖原有的值。 |
void |
setObjects(String key,
Object[] values)
设置参数值。和
add方法不同,此方法将覆盖原有的值。 |
void |
setProperties(Object object)
将数据保存到object properties中。
|
void |
setString(String key,
String value)
设置参数值。和
add方法不同,此方法将覆盖原有的值。 |
void |
setStrings(String key,
String[] values)
设置参数值。和
add方法不同,此方法将覆盖原有的值。 |
int |
size()
取得值的数量。
|
String |
toString()
转换成字符串。
|
protected static Logger logger
protected final org.springframework.beans.SimpleTypeConverter converter
protected final ParserWebContext webContext
public AbstractValueParser(ParserWebContext requestContext)
public org.springframework.beans.TypeConverter getTypeConverter()
ValueParsergetTypeConverter in interface ValueParserpublic int size()
size in interface ValueParserpublic boolean isEmpty()
isEmpty in interface ValueParsertruepublic boolean containsKey(String key)
containsKey in interface ValueParserkey - 要查找的参数名truepublic Set<String> keySet()
keySet in interface ValueParserpublic String[] getKeys()
getKeys in interface ValueParserpublic boolean getBoolean(String key)
false。getBoolean in interface ValueParserkey - 参数名public boolean getBoolean(String key, boolean defaultValue)
getBoolean in interface ValueParserkey - 参数名defaultValue - 默认值public byte getByte(String key)
0。getByte in interface ValueParserkey - 参数名public byte getByte(String key, byte defaultValue)
getByte in interface ValueParserkey - 参数名defaultValue - 默认值public byte[] getBytes(String key) throws UnsupportedEncodingException
getCharacterEncoding()所返回的字符集进行编码的。getBytes in interface ValueParserkey - 参数名nullUnsupportedEncodingException - 如果指定了错误的编码字符集public char getChar(String key)
'\0'。getChar in interface ValueParserkey - 参数名public char getChar(String key, char defaultValue)
getChar in interface ValueParserkey - 参数名defaultValue - 默认值public double getDouble(String key)
0。getDouble in interface ValueParserkey - 参数名public double getDouble(String key, double defaultValue)
getDouble in interface ValueParserkey - 参数名defaultValue - 默认值public float getFloat(String key)
0。getFloat in interface ValueParserkey - 参数名public float getFloat(String key, float defaultValue)
getFloat in interface ValueParserkey - 参数名defaultValue - 默认值public int getInt(String key)
0。getInt in interface ValueParserkey - 参数名public int getInt(String key, int defaultValue)
getInt in interface ValueParserkey - 参数名defaultValue - 默认值public int[] getInts(String key)
null。getInts in interface ValueParserkey - 参数名public int[] getInts(String key, int[] defaultValue)
getInts in interface ValueParserkey - 参数名defaultValue - 默认值public long getLong(String key)
0。getLong in interface ValueParserkey - 参数名public long getLong(String key, long defaultValue)
getLong in interface ValueParserkey - 参数名defaultValue - 默认值public long[] getLongs(String key)
null。getLongs in interface ValueParserkey - 参数名public long[] getLongs(String key, long[] defaultValue)
getLongs in interface ValueParserkey - 参数名defaultValue - 默认值public short getShort(String key)
0。getShort in interface ValueParserkey - 参数名public short getShort(String key, short defaultValue)
getShort in interface ValueParserkey - 参数名defaultValue - 默认值public String getString(String key)
null。getString in interface ValueParserkey - 参数名public String getString(String key, String defaultValue)
getString in interface ValueParserkey - 参数名defaultValue - 默认值public String[] getStrings(String key)
null。getStrings in interface ValueParserkey - 参数名public String[] getStrings(String key, String[] defaultValue)
getStrings in interface ValueParserkey - 参数名defaultValue - 默认值public Object get(String key)
null。 此方法和getObject
一样,但在模板中便易于使用。get in interface ValueParserkey - 参数名public Date getDate(String key, DateFormat format)
DateFormat来解析。如果不存在,则返回null。getDate in interface ValueParserkey - 参数名format - DateFormat对象java.util.Date对象public Date getDate(String key, DateFormat format, Date defaultValue)
DateFormat来解析。如果不存在,则返回默认值。getDate in interface ValueParserkey - 参数名format - DateFormat对象defaultValue - 默认值java.util.Date对象public Object getObject(String key)
null。getObject in interface ValueParserkey - 参数名public Object getObject(String key, Object defaultValue)
getObject in interface ValueParserkey - 参数名defaultValue - 默认值public Object[] getObjects(String key)
null。getObjects in interface ValueParserkey - 参数名public Object[] getObjects(String key, Object[] defaultValue)
getObjects in interface ValueParserkey - 参数名defaultValue - 默认值public <T> T getObjectOfType(String key, Class<T> type)
getObjectOfType in interface ValueParserpublic <T> T getObjectOfType(String key, Class<T> type, org.springframework.core.MethodParameter methodParameter, Object[] defaultValues)
getObjectOfType in interface ValueParserpublic void setProperties(Object object)
ValueParsersetProperties in interface ValueParserpublic void add(String key, boolean value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, byte value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, char value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, double value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, float value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, int value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, long value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, short value)
add in interface ValueParserkey - 参数名value - 参数值public void add(String key, Object value)
add in interface ValueParserkey - 参数名value - 参数值public void setString(String key, String value)
add方法不同,此方法将覆盖原有的值。setString in interface ValueParserkey - 参数名value - 参数值public void setStrings(String key, String[] values)
add方法不同,此方法将覆盖原有的值。setStrings in interface ValueParserkey - 参数名values - 参数值的数组public void setObject(String key, Object value)
add方法不同,此方法将覆盖原有的值。setObject in interface ValueParserkey - 参数名value - 参数值public void setObjects(String key, Object[] values)
add方法不同,此方法将覆盖原有的值。setObjects in interface ValueParserkey - 参数名values - 参数值public Object remove(String key)
remove in interface ValueParserString[]或nullpublic void clear()
clear in interface ValueParserprotected String convert(String key)
trim(),然后再进行大小写转换。转换是根据配置文件中的
url.case.folding来设定的。key - 要转换的参数名trim()和大小写转换后的参数名,如果是null,则转换成空字符串protected ValueList getValueList(String key, boolean create)
key - 参数名create - 如果参数不存在,是否创建之create==false,则返回nullprotected String getCharacterEncoding()
ParameterParser,
此编码字符集是由request.getCharacterEncoding()决定的。
默认总是返回ISO-8859-1。
Copyright © 2006–2018 TinyGroup. All rights reserved.