| java.lang.Object org.apache.velocity.tools.generic.ValueParser
All known Subclasses: org.apache.velocity.tools.view.tools.ParameterParser,
ValueParser | public class ValueParser (Code) | | Utility class for easy parsing of String values held in a Map.
Template example(s):
$parser.foo -> bar
$parser.getNumber('baz') -> 12.6
$parser.getInt('baz') -> 12
$parser.getNumbers('baz') -> [12.6]
Toolbox configuration:
<tool>
<key>parser</key>
<class>org.apache.velocity.generic.ValueParser</class>
</tool>
This comes in very handy when parsing parameters.
author: Nathan Bubna version: $Revision: 497988 $ $Date: 2007-01-19 14:48:13 -0800 (Fri, 19 Jan 2007) $ since: VelocityTools 1.2 |
ValueParser | public ValueParser()(Code) | | |
ValueParser | public ValueParser(Map source)(Code) | | |
exists | public boolean exists(String key)(Code) | | Convenience method for checking whether a certain parameter exists.
Parameters: key - the parameter's key true if a parameter exists for the specifiedkey; otherwise, returns false . |
get | public Object get(String key)(Code) | | Convenience method for use in Velocity templates.
This allows for easy "dot" access to parameters.
e.g. $params.foo instead of $params.getString('foo')
Parameters: key - the parameter's key parameter matching the specified key ornull if there is no matchingparameter |
getBoolean | public Boolean getBoolean(String key)(Code) | | Parameters: key - the desired parameter's key a Boolean object for the specified key ornull if no matching parameter is found |
getBoolean | public boolean getBoolean(String key, boolean alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate boolean value boolean value for the specified key or thealternate boolean is no value is found |
getBoolean | public Boolean getBoolean(String key, Boolean alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - the alternate Boolean a Boolean for the specified key or the specifiedalternate if no matching parameter is found |
getBooleans | public Boolean[] getBooleans(String key)(Code) | | Parameters: key - the key for the desired parameter an array of Boolean objects associated with the given key. |
getDouble | public Double getDouble(String key)(Code) | | Parameters: key - the desired parameter's key a Double for the specified key ornull if no matching parameter is found |
getDouble | public Double getDouble(String key, Double alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate Double an Double for the specified key or the specifiedalternate if no matching parameter is found |
getDouble | public double getDouble(String key, double alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate double value the double value for the specified key or the specifiedalternate value if no matching parameter is found |
getDoubles | public double[] getDoubles(String key)(Code) | | Parameters: key - the key for the desired parameter an array of double values associated with the given key,or null if numbers are not associated with it. |
getInt | public int getInt(String key, int alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate int value the int value for the specified key or the specifiedalternate value if no matching parameter is found |
getInteger | public Integer getInteger(String key)(Code) | | Parameters: key - the desired parameter's key a Integer for the specified key ornull if no matching parameter is found |
getInteger | public Integer getInteger(String key, Integer alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate Integer an Integer for the specified key or the specifiedalternate if no matching parameter is found |
getInts | public int[] getInts(String key)(Code) | | Parameters: key - the key for the desired parameter an array of int values associated with the given key,or null if numbers are not associated with it. |
getLocale | public Locale getLocale(String key)(Code) | | Parameters: key - the desired parameter's key a Locale for the specified key ornull if no matching parameter is found |
getLocale | public Locale getLocale(String key, Locale alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate Locale a Locale for the specified key or the specifiedalternate if no matching parameter is found |
getLocales | public Locale[] getLocales(String key)(Code) | | Parameters: key - the key for the desired parameter an array of Locale objects associated with the given key,or null if Locales are not associated with it. |
getNumber | public Number getNumber(String key)(Code) | | Parameters: key - the desired parameter's key a Number for the specified key ornull if no matching parameter is found |
getNumber | public Number getNumber(String key, Number alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate Number a Number for the specified key or the specifiedalternate if no matching parameter is found |
getNumbers | public Number[] getNumbers(String key)(Code) | | Parameters: key - the key for the desired parameter an array of Number objects associated with the given key,or null if Numbers are not associated with it. |
getString | public String getString(String key)(Code) | | Parameters: key - the parameter's key parameter matching the specified key ornull if there is no matchingparameter |
getString | public String getString(String key, String alternate)(Code) | | Parameters: key - the desired parameter's key Parameters: alternate - The alternate value parameter matching the specified key or thespecified alternate String if there is no matchingparameter |
getStrings | public String[] getStrings(String key)(Code) | | Parameters: key - the key for the desired parameter an array of String objects containing all of the valuesassociated with the given key, or null if the no values are associated with the given key |
getStringsDelimiter | final protected String getStringsDelimiter()(Code) | | Returns the delimiter used for separating values in a single String value.
The default delimiter is a comma.
since: VelocityTools 1.3 See Also: ValueParser.parseStringList |
parseBoolean | protected Boolean parseBoolean(String value)(Code) | | Converts a parameter value into a
Boolean Sub-classes can override to allow for customized boolean parsing.
(e.g. to handle "Yes/No" or "T/F")
Parameters: value - the string to be parsed the value as a Boolean |
parseLocale | protected Locale parseLocale(String value)(Code) | | Converts a String value into a Locale.
since: VelocityTools 1.3 |
parseNumber | protected Number parseNumber(String value) throws NumberFormatException(Code) | | Converts a parameter value into a
Number This is used as the base for all numeric parsing methods. So,
sub-classes can override to allow for customized number parsing.
(e.g. to handle fractions, compound numbers, etc.)
Parameters: value - the string to be parsed the value as a Number |
parseStringList | protected String[] parseStringList(String value)(Code) | | Converts a single String value into an array of Strings by splitting
it on the tool's set delimiter. The default delimiter is a comma.
since: VelocityTools 1.3 |
setSource | protected void setSource(Map source)(Code) | | |
setStringsDelimiter | final protected void setStringsDelimiter(String delimiter)(Code) | | Sets the delimiter used for separating values in a single String value.
The default delimiter is a comma.
since: VelocityTools 1.3 See Also: ValueParser.parseStringList |
|
|