|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.generic.SafeConfig org.apache.velocity.tools.generic.LocaleConfig org.apache.velocity.tools.generic.ConversionTool org.apache.velocity.tools.generic.ValueParser
@DefaultKey(value="parser") public class ValueParser
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
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
private boolean |
allowSubkeys
|
static java.lang.String |
ALLOWSUBKEYS_KEY
The key used for specifying whether to support subkeys |
private java.lang.Boolean |
hasSubkeys
|
private boolean |
readOnly
|
static java.lang.String |
READONLY_KEY
The key used for specifying whether to be read-only |
private java.util.Map<java.lang.String,java.lang.Object> |
source
|
Fields inherited from class org.apache.velocity.tools.generic.ConversionTool |
---|
DATE_FORMAT_KEY, DEFAULT_DATE_FORMAT, DEFAULT_NUMBER_FORMAT, DEFAULT_STRINGS_DELIMITER, DEFAULT_STRINGS_TRIM, NUMBER_FORMAT_KEY, STRINGS_DELIMITER_FORMAT_KEY, STRINGS_TRIM_KEY |
Fields inherited from class org.apache.velocity.tools.generic.LocaleConfig |
---|
DEFAULT_LOCALE |
Fields inherited from class org.apache.velocity.tools.generic.SafeConfig |
---|
LOCK_CONFIG_KEY, OLD_LOCK_CONFIG_KEY, SAFE_MODE_KEY |
Constructor Summary | |
---|---|
ValueParser()
|
|
ValueParser(java.util.Map<java.lang.String,java.lang.Object> source)
|
Method Summary | |
---|---|
void |
clear()
|
protected void |
configure(ValueParser values)
Does the actual configuration. |
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()
|
boolean |
exists(java.lang.String key)
Convenience method for checking whether a certain parameter exists. |
java.lang.Object |
get(java.lang.Object key)
|
java.lang.Object |
get(java.lang.String key)
Convenience method for use in Velocity templates. |
protected boolean |
getAllowSubkeys()
Are subkeys allowed ? |
java.lang.Boolean |
getBoolean(java.lang.String key)
|
boolean |
getBoolean(java.lang.String key,
boolean alternate)
|
java.lang.Boolean |
getBoolean(java.lang.String key,
java.lang.Boolean alternate)
|
java.lang.Boolean[] |
getBooleans(java.lang.String key)
|
java.lang.Double |
getDouble(java.lang.String key)
|
double |
getDouble(java.lang.String key,
double alternate)
|
java.lang.Double |
getDouble(java.lang.String key,
java.lang.Double alternate)
|
double[] |
getDoubles(java.lang.String key)
|
int |
getInt(java.lang.String key,
int alternate)
|
java.lang.Integer |
getInteger(java.lang.String key)
|
java.lang.Integer |
getInteger(java.lang.String key,
java.lang.Integer alternate)
|
int[] |
getInts(java.lang.String key)
|
java.util.Locale |
getLocale(java.lang.String key)
|
java.util.Locale |
getLocale(java.lang.String key,
java.util.Locale alternate)
|
java.util.Locale[] |
getLocales(java.lang.String key)
|
java.lang.Number |
getNumber(java.lang.String key)
|
java.lang.Number |
getNumber(java.lang.String key,
java.lang.Number alternate)
|
java.lang.Number[] |
getNumbers(java.lang.String key)
|
protected boolean |
getReadOnly()
Is the Map read-only? |
protected java.util.Map<java.lang.String,java.lang.Object> |
getSource()
|
java.lang.String |
getString(java.lang.String key)
|
java.lang.String |
getString(java.lang.String key,
java.lang.String alternate)
|
java.lang.String[] |
getStrings(java.lang.String key)
|
protected ValueParser |
getSubkey(java.lang.String subkey)
subkey getter that returns a map |
java.lang.Object |
getValue(java.lang.String key)
Returns the value mapped to the specified key in the Map returned by getSource() . |
java.lang.Object |
getValue(java.lang.String key,
java.lang.Object alternate)
|
java.lang.Object[] |
getValues(java.lang.String key)
|
boolean |
hasSubkeys()
Determines whether there are subkeys available in the source map. |
boolean |
isEmpty()
|
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> m)
|
java.lang.Object |
remove(java.lang.Object key)
|
protected void |
setAllowSubkeys(boolean allow)
allow or disallow subkeys |
protected void |
setReadOnly(boolean ro)
Set or unset read-only behaviour |
protected void |
setSource(java.util.Map<java.lang.String,java.lang.Object> source)
|
int |
size()
|
java.lang.String |
toString()
|
java.util.Collection |
values()
|
Methods inherited from class org.apache.velocity.tools.generic.ConversionTool |
---|
getDateFormat, getNumberFormat, getStringsDelimiter, getStringsTrim, parseBoolean, parseDate, parseDate, parseDate, parseDate, parseDate, parseLocale, parseNumber, parseNumber, parseNumber, parseNumber, parseStringList, setDateFormat, setNumberFormat, setStringsDelimiter, setStringsTrim, toBoolean, toBooleans, toBooleans, toCalendar, toCalendars, toCalendars, toDate, toDates, toDates, toDouble, toDoubles, toInteger, toIntegers, toInts, toLocale, toLocales, toLocales, toNumber, toNumbers, toNumbers, toString, toStrings |
Methods inherited from class org.apache.velocity.tools.generic.LocaleConfig |
---|
getLocale, setLocale |
Methods inherited from class org.apache.velocity.tools.generic.SafeConfig |
---|
configure, isConfigLocked, isSafeMode, setLockConfig, setSafeMode |
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 |
---|
private java.util.Map<java.lang.String,java.lang.Object> source
private boolean allowSubkeys
private java.lang.Boolean hasSubkeys
private boolean readOnly
public static final java.lang.String ALLOWSUBKEYS_KEY
public static final java.lang.String READONLY_KEY
Constructor Detail |
---|
public ValueParser()
public ValueParser(java.util.Map<java.lang.String,java.lang.Object> source)
Method Detail |
---|
protected void setSource(java.util.Map<java.lang.String,java.lang.Object> source)
protected java.util.Map<java.lang.String,java.lang.Object> getSource()
protected boolean getAllowSubkeys()
protected void setAllowSubkeys(boolean allow)
allow
- protected boolean getReadOnly()
protected void setReadOnly(boolean ro)
ro
- protected void configure(ValueParser values)
configure
in class ConversionTool
public boolean exists(java.lang.String key)
key
- the parameter's key
true
if a parameter exists for the specified
key; otherwise, returns false
.public java.lang.Object get(java.lang.String key)
key
- the parameter's key
null
if there is no matching
parameterpublic java.lang.Object getValue(java.lang.String key)
Map
returned by getSource()
. If there is
no source, then this will always return null
.
public java.lang.Object getValue(java.lang.String key, java.lang.Object alternate)
key
- the desired parameter's keyalternate
- The alternate value
public java.lang.Object[] getValues(java.lang.String key)
public java.lang.String getString(java.lang.String key)
key
- the parameter's key
null
if there is no matching
parameterpublic java.lang.String getString(java.lang.String key, java.lang.String alternate)
key
- the desired parameter's keyalternate
- The alternate value
public java.lang.Boolean getBoolean(java.lang.String key)
key
- the desired parameter's key
Boolean
object for the specified key or
null
if no matching parameter is foundpublic boolean getBoolean(java.lang.String key, boolean alternate)
key
- the desired parameter's keyalternate
- The alternate boolean value
public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean alternate)
key
- the desired parameter's keyalternate
- the alternate Boolean
Boolean
for the specified key or the specified
alternate if no matching parameter is foundpublic java.lang.Integer getInteger(java.lang.String key)
key
- the desired parameter's key
Integer
for the specified key or
null
if no matching parameter is foundpublic java.lang.Integer getInteger(java.lang.String key, java.lang.Integer alternate)
key
- the desired parameter's keyalternate
- The alternate Integer
public java.lang.Double getDouble(java.lang.String key)
key
- the desired parameter's key
Double
for the specified key or
null
if no matching parameter is foundpublic java.lang.Double getDouble(java.lang.String key, java.lang.Double alternate)
key
- the desired parameter's keyalternate
- The alternate Double
public java.lang.Number getNumber(java.lang.String key)
key
- the desired parameter's key
Number
for the specified key or
null
if no matching parameter is foundpublic java.util.Locale getLocale(java.lang.String key)
key
- the desired parameter's key
Locale
for the specified key or
null
if no matching parameter is foundpublic java.lang.Number getNumber(java.lang.String key, java.lang.Number alternate)
key
- the desired parameter's keyalternate
- The alternate Number
public int getInt(java.lang.String key, int alternate)
key
- the desired parameter's keyalternate
- The alternate int value
public double getDouble(java.lang.String key, double alternate)
key
- the desired parameter's keyalternate
- The alternate double value
public java.util.Locale getLocale(java.lang.String key, java.util.Locale alternate)
key
- the desired parameter's keyalternate
- The alternate Locale
public java.lang.String[] getStrings(java.lang.String key)
key
- the key for the desired parameter
null
if the no values are associated with the given keypublic java.lang.Boolean[] getBooleans(java.lang.String key)
key
- the key for the desired parameter
public java.lang.Number[] getNumbers(java.lang.String key)
key
- the key for the desired parameter
null
if Numbers are not associated with it.public int[] getInts(java.lang.String key)
key
- the key for the desired parameter
null
if numbers are not associated with it.public double[] getDoubles(java.lang.String key)
key
- the key for the desired parameter
null
if numbers are not associated with it.public java.util.Locale[] getLocales(java.lang.String key)
key
- the key for the desired parameter
null
if Locales are not associated with it.public boolean hasSubkeys()
protected ValueParser getSubkey(java.lang.String subkey)
subkey
- subkey to search for
public int size()
size
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object put(java.lang.String key, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,java.lang.Object>
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> m)
putAll
in interface java.util.Map<java.lang.String,java.lang.Object>
public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Collection values()
values
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |