| java.lang.Object com.izforge.izpack.util.VariableSubstitutor
VariableSubstitutor | public class VariableSubstitutor implements Serializable(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 |
TYPE_ANT | final protected static int TYPE_ANT(Code) | | A constant for file type. Plain file with ANT-like variable markers, ie @param@
|
TYPE_AT | final protected static int TYPE_AT(Code) | | A constant for file type. Plain file with '@' start char.
|
TYPE_JAVA | final protected static int TYPE_JAVA(Code) | | A constant for file type. Java file, where \ have to be escaped.
|
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.
|
bracesRequired | protected boolean bracesRequired(Code) | | Whether braces are required for substitution.
|
typeNameToConstantMap | final protected static Map<String, Integer> typeNameToConstantMap(Code) | | A mapping of file type names to corresponding integer constants.
|
variables | protected transient Properties variables(Code) | | The variable value mappings
|
VariableSubstitutor | public VariableSubstitutor(Properties variables)(Code) | | Constructs a new substitutor using the specified variable value mappings. The environment
hashtable is copied by reference. Braces are not required by default
Parameters: variables - the map with variable value mappings |
areBracesRequired | public boolean areBracesRequired()(Code) | | Get whether this substitutor requires braces.
|
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 |
setBracesRequired | public void setBracesRequired(boolean braces)(Code) | | Specify whether this substitutor requires braces.
|
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 int 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 the number of substitutions made |
|
|