public class StringTemplateParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_MACRO_END |
static java.lang.String |
DEFAULT_MACRO_PREFIX |
static java.lang.String |
DEFAULT_MACRO_START |
protected char |
escapeChar |
protected java.lang.String |
macroEnd |
protected java.lang.String |
macroPrefix |
protected java.lang.String |
macroStart |
protected java.lang.String |
missingKeyReplacement |
protected boolean |
parseValues |
protected boolean |
replaceMissingKey |
protected boolean |
resolveEscapes |
Constructor and Description |
---|
StringTemplateParser() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
parse(java.lang.String template,
java.util.function.Function<java.lang.String,java.lang.String> macroResolver)
Parses string template and replaces macros with resolved values.
|
StringTemplateParser |
setEscapeChar(char escapeChar)
Defines escape character.
|
StringTemplateParser |
setMacroEnd(java.lang.String macroEnd)
Defines macro end string.
|
StringTemplateParser |
setMacroPrefix(java.lang.String macroPrefix) |
StringTemplateParser |
setMacroStart(java.lang.String macroStart)
Defines macro start string.
|
StringTemplateParser |
setMissingKeyReplacement(java.lang.String missingKeyReplacement)
Specifies replacement for missing keys.
|
StringTemplateParser |
setParseValues(boolean parseValues)
Defines if macro values has to be parsed, too.
|
StringTemplateParser |
setReplaceMissingKey(boolean replaceMissingKey)
Specifies if missing keys should be resolved at all,
true by default. |
StringTemplateParser |
setResolveEscapes(boolean resolveEscapes)
Specifies if escaped values should be resolved.
|
StringTemplateParser |
setStrictFormat()
Sets the strict format by setting the macro prefix to
null . |
public static final java.lang.String DEFAULT_MACRO_PREFIX
public static final java.lang.String DEFAULT_MACRO_START
public static final java.lang.String DEFAULT_MACRO_END
protected boolean replaceMissingKey
protected java.lang.String missingKeyReplacement
protected boolean resolveEscapes
protected java.lang.String macroPrefix
protected java.lang.String macroStart
protected java.lang.String macroEnd
protected char escapeChar
protected boolean parseValues
public StringTemplateParser setReplaceMissingKey(boolean replaceMissingKey)
true
by default.
If false
missing keys will be left as it were, i.e.
they will not be replaced.public StringTemplateParser setMissingKeyReplacement(java.lang.String missingKeyReplacement)
null
exception will be thrown.public StringTemplateParser setResolveEscapes(boolean resolveEscapes)
false
so escaped values
remains.public StringTemplateParser setMacroStart(java.lang.String macroStart)
public StringTemplateParser setMacroPrefix(java.lang.String macroPrefix)
public StringTemplateParser setMacroEnd(java.lang.String macroEnd)
public StringTemplateParser setStrictFormat()
null
.public StringTemplateParser setEscapeChar(char escapeChar)
public StringTemplateParser setParseValues(boolean parseValues)
public java.lang.String parse(java.lang.String template, java.util.function.Function<java.lang.String,java.lang.String> macroResolver)
Copyright © 2003-present Jodd Team