| java.lang.Object sunlabs.brazil.util.Format
Format | public class Format (Code) | | Format a string by substituting values into it,
either from an array of strings, or a properties object.
author: colin stevens author: stephen uhler |
Method Summary | |
public static String | fmt(String format, Object[] array) Foreach instance of %i (i = 1...9) in the format parameter,
replace it with the value of ith element of the
array, by calling its toString method.
Parameters: format - String containing %n... | public static String | fmt(String format, Properties props) Foreach instance of %key% in the format parameter,
replace it with the value of key in the properties, or the
empty string if key is not found. | public static String | fmt(String format, Object[] array, Properties props) | public static String | getProperty(Properties props, String expr, String defaultValue) Allow a property name to contain the value of another
property, permitting nested variable substitution in attribute
values. | public static String | subst(Dictionary props, String str) Allow a tag attribute value to contain the value of another
property, permitting nested variable substitution in attribute
values. |
fmt | public static String fmt(String format, Object[] array)(Code) | | Foreach instance of %i (i = 1...9) in the format parameter,
replace it with the value of ith element of the
array, by calling its toString method.
Parameters: format - String containing %n... sequences Parameters: array - The array of values to substitute intothe format string. |
fmt | public static String fmt(String format, Properties props)(Code) | | Foreach instance of %key% in the format parameter,
replace it with the value of key in the properties, or the
empty string if key is not found.
Parameters: format - String containing %key...% sequences Parameters: props - Properties to match the keys,and replace them with their corrosponding values. |
getProperty | public static String getProperty(Properties props, String expr, String defaultValue)(Code) | | Allow a property name to contain the value of another
property, permitting nested variable substitution in attribute
values. The name of the embedded property to be substituted is
bracketted by "${" and "}". See
Format.subst .
"ghi" => "foo"
"deffoojkl" => "baz"
"abcbazmno" => "garply"
getProperty("ghi") => "foo"
getProperty("def${ghi}jkl") => "baz"
getProperty("abc${def${ghi}jkl}mno") => "garply"
Parameters: props - The table of variables to use when substituting. Parameters: expr - The property name, prossibly containing substitutions. Parameters: defaultValue - The value to use if the top-level substitution does notexist. May be null . |
subst | public static String subst(Dictionary props, String str)(Code) | | Allow a tag attribute value to contain the value of another
property, permitting nested variable substitution in attribute
values. To escape ${XXX}, use $\{XXX\}. The "\" is only special
when it is in front of "{" or "}" (This behavior is unfortunate,
and may change in the future).
"ghi" => "foo"
"deffoojkl" => "baz"
"abcbazmno" => "garply"
subst("ghi") => "ghi"
subst("def${ghi}jkl") => "deffoojkl"
subst("abc${def${ghi}jkl}mno") => "abcbazmno"
subst("${abc${def${ghi}jkl}mno}") => "garply"
Parameters: props - The table of variables to substitute.If this is a Properties object, then thegetProperty() method is used instead of theDictionary class get() method. Parameters: str - The expression containing the substitutions.Embedded property names, bracketted by "${" and "}" are looked up in the props table and replaced withtheir value. Nested substitutions are allowed. |
|
|