|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcds.util.Macro
Manages macro substitution in a string.
The string can contain parameters like $PARAM ou ${PARAM}, where
the parameter designation character ('$' by default) can be changed.
Several ways will feed the macro object with the values for such parameters.
A substitution returns the the string with the values replacing the
corresponding parameters.
Field Summary | |
private static char |
DELIM_CHAR_BEGIN
|
private static char |
DELIM_CHAR_END
|
private static char |
ESC_CHAR
|
private char |
param_char
|
private static char |
PARAM_CHAR
|
(package private) java.util.Hashtable |
paramList
|
Constructor Summary | |
Macro()
Empty constructor. |
|
Macro(java.util.Hashtable ht)
Constructor receiving a hastable of parameters |
|
Macro(Macro mac)
Constructor receiving a Macro object for its initialization |
Method Summary | |
void |
addParam(java.util.Hashtable ht)
Adds a Hashtable of parameters to this macro object |
void |
addParam(java.lang.String name,
java.lang.String value)
Adds a parameter tothe current hashtable |
java.lang.String[] |
getParameters(java.lang.String str)
Returns the list of parameters contained in a string. |
static java.lang.String[] |
getParameters(java.lang.String str,
char parameterChar)
Returns the list of parameters contained in a string. |
char |
setParameterChar(char c)
Change the character used to define a parameter (default is '$') |
java.lang.String |
substitute(java.lang.String str)
Substitute the defined parameters in the given string |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final char PARAM_CHAR
private static final char DELIM_CHAR_BEGIN
private static final char DELIM_CHAR_END
private static final char ESC_CHAR
private char param_char
java.util.Hashtable paramList
Constructor Detail |
public Macro()
public Macro(java.util.Hashtable ht)
ht
- Hashtable of parameterspublic Macro(Macro mac)
Method Detail |
public char setParameterChar(char c)
c
- new char to use for defining a parameter
public void addParam(java.util.Hashtable ht)
ht
- Hashtable of parameterspublic void addParam(java.lang.String name, java.lang.String value)
name
- name of the parametervalue
- value of the parameter (string to substitute)public java.lang.String substitute(java.lang.String str) throws java.text.ParseException
str
- String containing parameters to substitute
java.text.ParseException
- if a parameter is absent or braces are not closedpublic java.lang.String[] getParameters(java.lang.String str)
str
- string to analyse
public static java.lang.String[] getParameters(java.lang.String str, char parameterChar)
str
- string to analyseparameterChar
- defines a particular character for parameter designation
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |