public class MacroExpander
extends java.lang.Object
Constructor and Description |
---|
MacroExpander()
Initiate a parser for parsing macros of the form "${xxx}".
|
MacroExpander(java.lang.String startDelim, java.lang.String endDelim, boolean recursiveParse, boolean sanitizedMacroKeys) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
expand(java.lang.String macro, java.util.Map<java.lang.String,java.lang.String> macroValues)
Expand macros substituting macro-values from a Map.
|
boolean |
isRecursiveParse() |
boolean |
isSanitizedMacroKeys() |
void |
setRecursiveParse(boolean recursiveParse) |
void |
setSanitizedMacroKeys(boolean sanitizedMacroKeys)
Should macro keys passed in the Map of macro values be considered to be free of the macro delimiters.
|
public MacroExpander()
public MacroExpander(java.lang.String startDelim, java.lang.String endDelim, boolean recursiveParse, boolean sanitizedMacroKeys)
startDelim
- starting delimitedendDelim
- ending delimiterrecursiveParse
- whether substituted values should be parsed again, this allows macros within macro-values, for e.g. if macro is ${${component}} and key-value Map issanitizedMacroKeys
- whether the keys in the 'macrovalues' Map passed to expand() are stripped of delimiters. Default is false.public java.lang.String expand(java.lang.String macro, java.util.Map<java.lang.String,java.lang.String> macroValues)
macro
- the macro to parse.macroValues
- a Map contain macro key-value pairs. If sanitizedMacroValues is true then the keys should not contain delimiters.java.lang.IllegalArgumentException
- if the macro has syntax errorsjava.util.NoSuchElementException
- if a macro could not be resolved by the Map and if recursive parsing is enabled (default). If recursive parsing is disabled, the macro is left unexpanded.public void setRecursiveParse(boolean recursiveParse)
public boolean isRecursiveParse()
public void setSanitizedMacroKeys(boolean sanitizedMacroKeys)
sanitizedMacroKeys
- set to false if MacroExpander should strip delimiters from the keys before considering them for a match.public boolean isSanitizedMacroKeys()