类 ValueParser
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.LocaleConfig
org.apache.velocity.tools.generic.FormatConfig
org.apache.velocity.tools.generic.ValueParser
@DefaultKey("parser")
@InvalidScope("session")
@SkipSetters
public class ValueParser
extends FormatConfig
implements Map<String,Object>
Utility class for easy parsing of String values held in a Map.
This comes in very handy when parsing parameters.
When subkeys are allowed, getValue("foo") will also search for all keys of the form "foo.bar" and return a ValueParser of the type "bar" -> value for all found values.
TODO: someone doing java configuration ought to be able to put a source Map in the tool properties, allowing this to be used like other tools- 从以下版本开始:
- VelocityTools 1.2
- 版本:
- $Revision$ $Date$
- 作者:
- Nathan Bubna
-
嵌套类概要
-
字段概要
字段修饰符和类型字段说明static final StringThe key used for specifying whether to support subkeysstatic final Stringstatic final StringThe key used for specifying whether to be read-onlystatic final String从类继承的字段 org.apache.velocity.tools.generic.FormatConfig
DEFAULT_FORMAT, FORMAT_KEY从类继承的字段 org.apache.velocity.tools.generic.LocaleConfig
DEFAULT_LOCALE从类继承的字段 org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclear()protected voidconfigure(ValueParser values) Does the actual configuration.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanConvenience method for checking whether a certain parameter exists.Convenience method for use in Velocity templates.protected booleanAre subkeys allowed ?getBoolean(String key) booleangetBoolean(String key, boolean alternate) getBoolean(String key, Boolean alternate) Boolean[]getBooleans(String key) doubledouble[]getDoubles(String key) intgetInteger(String key) getInteger(String key, Integer alternate) int[]Locale[]getLocales(String key) Number[]getNumbers(String key) protected booleanIs the Map read-only?getSource(boolean create) String[]getStrings(String key) subkey getter that returns a map subkey#2 -> value for every "subkey.subkey2" found entryreturns the set of all possible first-level subkeys, including complete keys without dots (or returns keySet() if allowSubKeys is false)Returns the value mapped to the specified key in theMapreturned bygetSource().Object[]Returns an array of values.booleanDetermines whether there are subkeys available in the source map.booleanisEmpty()keySet()protected String[]parseStringList(String value) voidprotected voidsetAllowSubkeys(boolean allow) allow or disallow subkeysprotected voidsetReadOnly(boolean ro) Set or unset read-only behaviourprotected voidprotected final voidsetStringsDelimiter(String stringsDelimiter) Sets the delimiter used for separating values in a single String value.intsize()toString()values()从类继承的方法 org.apache.velocity.tools.generic.FormatConfig
getFormat, setFormat从类继承的方法 org.apache.velocity.tools.generic.LocaleConfig
getLocale, setLocale, toLocale从类继承的方法 org.apache.velocity.tools.generic.SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
字段详细资料
-
构造器详细资料
-
ValueParser
public ValueParser() -
ValueParser
-
-
方法详细资料
-
setSource
-
getSource
-
getSource
-
getAllowSubkeys
protected boolean getAllowSubkeys()Are subkeys allowed ?- 返回:
- yes/no
-
setAllowSubkeys
protected void setAllowSubkeys(boolean allow) allow or disallow subkeys- 参数:
allow- flag value
-
getReadOnly
protected boolean getReadOnly()Is the Map read-only?- 返回:
- yes/no
-
setReadOnly
protected void setReadOnly(boolean ro) Set or unset read-only behaviour- 参数:
ro- flag value
-
setStringsDelimiter
Sets the delimiter used for separating values in a single String value. The default string delimiter is a comma.- 参数:
stringsDelimiter- strings delimiter- 另请参阅:
-
configure
Does the actual configuration. This is protected, so subclasses may share the same ValueParser and call configure at any time, while preventing templates from doing so when configure(Map) is locked.- 覆盖:
configure在类中FormatConfig- 参数:
values- configuration values
-
exists
Convenience method for checking whether a certain parameter exists.- 参数:
key- the parameter's key- 返回:
trueif a parameter exists for the specified key; otherwise, returnsfalse.
-
get
Convenience method for use in Velocity templates. This allows for easy "dot" access to parameters. e.g. $params.foo instead of $params.getString('foo')- 参数:
key- the parameter's key- 返回:
- parameter matching the specified key or
nullif there is no matching parameter
-
getValue
Returns the value mapped to the specified key in theMapreturned bygetSource(). If there is no source, then this will always returnnull.- 参数:
key- property key- 返回:
- property value, or null
-
getValue
- 参数:
key- the desired parameter's keyalternate- The alternate value- 返回:
- parameter matching the specified key or the specified alternate Object if there is no matching parameter
-
parseStringList
-
getValues
Returns an array of values. If the internal value is a string, it is split using the configured delimitor (',' by default).
If the internal value is not an array or is a string without any delimiter, a singletin array is returned.
- 参数:
key- the desired parameter's key- 返回:
- array of values, or null of the key has not been found. specified alternate Object if there is no matching parameter
-
getString
- 参数:
key- the parameter's key- 返回:
- parameter matching the specified key or
nullif there is no matching parameter
-
getString
- 参数:
key- the desired parameter's keyalternate- The alternate value- 返回:
- parameter matching the specified key or the specified alternate String if there is no matching parameter
-
getBoolean
- 参数:
key- the desired parameter's key- 返回:
- a
Booleanobject for the specified key ornullif no matching parameter is found
-
getBoolean
- 参数:
key- the desired parameter's keyalternate- The alternate boolean value- 返回:
- boolean value for the specified key or the alternate boolean is no value is found
-
getBoolean
-
getInteger
- 参数:
key- the desired parameter's key- 返回:
- a
Integerfor the specified key ornullif no matching parameter is found
-
getInteger
- 参数:
key- the desired parameter's keyalternate- The alternate Integer- 返回:
- an Integer for the specified key or the specified alternate if no matching parameter is found
-
getLong
- 参数:
key- the desired parameter's key- 返回:
- a
Longfor the specified key ornullif no matching parameter is found
-
getLong
- 参数:
key- the desired parameter's keyalternate- The alternate Long- 返回:
- a Long for the specified key or the specified alternate if no matching parameter is found
-
getDouble
- 参数:
key- the desired parameter's key- 返回:
- a
Doublefor the specified key ornullif no matching parameter is found
-
getDouble
- 参数:
key- the desired parameter's keyalternate- The alternate Double- 返回:
- an Double for the specified key or the specified alternate if no matching parameter is found
-
getNumber
- 参数:
key- the desired parameter's key- 返回:
- a
Numberfor the specified key ornullif no matching parameter is found
-
getLocale
- 参数:
key- the desired parameter's key- 返回:
- a
Localefor the specified key ornullif no matching parameter is found
-
getNumber
- 参数:
key- the desired parameter's keyalternate- The alternate Number- 返回:
- a Number for the specified key or the specified alternate if no matching parameter is found
-
getInt
- 参数:
key- the desired parameter's keyalternate- The alternate int value- 返回:
- the int value for the specified key or the specified alternate value if no matching parameter is found
-
getDouble
- 参数:
key- the desired parameter's keyalternate- The alternate double value- 返回:
- the double value for the specified key or the specified alternate value if no matching parameter is found
-
getLocale
- 参数:
key- the desired parameter's keyalternate- The alternate Locale- 返回:
- a Locale for the specified key or the specified alternate if no matching parameter is found
-
getStrings
- 参数:
key- the key for the desired parameter- 返回:
- an array of String objects containing all of the values
associated with the given key, or
nullif the no values are associated with the given key
-
getBooleans
- 参数:
key- the key for the desired parameter- 返回:
- an array of Boolean objects associated with the given key.
-
getNumbers
- 参数:
key- the key for the desired parameter- 返回:
- an array of Number objects associated with the given key,
or
nullif Numbers are not associated with it.
-
getInts
- 参数:
key- the key for the desired parameter- 返回:
- an array of int values associated with the given key,
or
nullif numbers are not associated with it.
-
getDoubles
- 参数:
key- the key for the desired parameter- 返回:
- an array of double values associated with the given key,
or
nullif numbers are not associated with it.
-
getLocales
- 参数:
key- the key for the desired parameter- 返回:
- an array of Locale objects associated with the given key,
or
nullif Locales are not associated with it.
-
hasSubkeys
public boolean hasSubkeys()Determines whether there are subkeys available in the source map.- 返回:
trueif there are subkeys (key names containing a dot)
-
getSubkeys
returns the set of all possible first-level subkeys, including complete keys without dots (or returns keySet() if allowSubKeys is false)- 返回:
- the set of all possible first-level subkeys
-
getSubkey
subkey getter that returns a map subkey#2 -> value for every "subkey.subkey2" found entry- 参数:
subkey- subkey to search for- 返回:
- the map of found values
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- 指定者:
containsKey在接口中Map<String,Object>
-
containsValue
- 指定者:
containsValue在接口中Map<String,Object>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
toString
-