| java.lang.Object com.izforge.izpack.installer.VariableSubstitutor
VariableSubstitutor | public class VariableSubstitutor (Code) | | Substitutes variables occurring in an input stream or a string. This
implementation supports a generic variable value mapping and escapes the
possible special characters occurring in the substituted values. The file
types specifically supported are plain text files (no escaping), Java
properties files, and XML files. A valid variable name matches the regular
expression [a-zA-Z][a-zA-Z0-9_]* and names are case sensitive. Variables are
referenced either by $NAME or ${NAME} (the latter syntax being useful in
situations like ${NAME}NOTPARTOFNAME). If a referenced variable is undefined
then it is not substituted but the corresponding part of the stream is
copied as is.
author: Johannes Lehtinen |
Constructor Summary | |
public | VariableSubstitutor(Map variables) Constructs a new substitutor using the specified variable value mappings. |
TYPE_JAVA_PROPERTIES | final protected static int TYPE_JAVA_PROPERTIES(Code) | | A constant for file type. Java properties file.
|
TYPE_PLAIN | final protected static int TYPE_PLAIN(Code) | | A constant for file type. Plain file.
|
TYPE_SHELL | final protected static int TYPE_SHELL(Code) | | A constant for file type. Shell file.
|
TYPE_XML | final protected static int TYPE_XML(Code) | | A constant for file type. XML file.
|
typeNameToConstantMap | protected static Map typeNameToConstantMap(Code) | | A mapping of file type names to corresponding integer constants.
|
variables | protected Map variables(Code) | | The variable value mappings
|
VariableSubstitutor | public VariableSubstitutor(Map variables)(Code) | | Constructs a new substitutor using the specified variable value mappings.
The given map is copied by reference.
Parameters: variables - the map with variable value mappings |
escapeSpecialChars | protected String escapeSpecialChars(String str, int type)(Code) | | Escapes the special characters in the specified string using file type
specific rules.
Parameters: str - the string to check for special characters Parameters: type - the target file type (one of TYPE_xxx) the string with the special characters properly escaped |
getTypeConstant | protected int getTypeConstant(String type)(Code) | | Returns the internal constant for the specified file type.
Parameters: type - the type name or null for plain the file type constant |
substitute | public String substitute(String str, String type) throws IllegalArgumentException(Code) | | Substitutes the variables found in the specified string. Escapes special
characters using file type specific escaping if necessary.
Parameters: str - the string to check for variables Parameters: type - the escaping type or null for plain the string with substituted variables exception: IllegalArgumentException - if unknown escaping type specified |
substitute | public void substitute(Reader reader, Writer writer, String type) throws IllegalArgumentException, IOException(Code) | | Substitutes the variables found in the data read from the specified
reader. Escapes special characters using file type specific escaping if
necessary.
Parameters: reader - the reader to read Parameters: writer - the writer used to write data out Parameters: type - the file type or null for plain exception: IllegalArgumentException - if unknown file type specified exception: IOException - if an I/O error occurs |
|
|