public class Variable extends java.lang.Object implements TemplateEntry
TemplateEntry
that inserts the value of a variable.
Variables starting with "special:" form a separate namespace and provide actions other than simple key-value lookup.
A variable with no mapping for a given data provider will be considered not "valid"
(see TemplateEntry.isValid(TemplateEngineDataProvider)
).
Modifier and Type | Field and Description |
---|---|
private boolean |
special |
private static java.lang.String |
SPECIAL_VALUE_EVERYTHING |
private static java.lang.String |
SPECIAL_VARIABLE_PREFIX |
private java.lang.String |
variableName |
Constructor and Description |
---|
Variable(java.lang.String variableName)
Constructs a new
Variable . |
Modifier and Type | Method and Description |
---|---|
void |
appendText(java.lang.StringBuilder result,
TemplateEngineDataProvider dataProvider)
Execute this template by generating text for a given data provider.
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
boolean |
isSpecial()
Check if this variable is special.
|
boolean |
isValid(TemplateEngineDataProvider dataProvider)
Check if this template is applicable to the given data provider.
|
java.lang.String |
toString() |
private static final java.lang.String SPECIAL_VARIABLE_PREFIX
private static final java.lang.String SPECIAL_VALUE_EVERYTHING
private final java.lang.String variableName
private final boolean special
public Variable(java.lang.String variableName)
Variable
.variableName
- the variable name (i.e. the key in the data provider key-value mapping);
will be considered "special" if the variable name starts with SPECIAL_VARIABLE_PREFIX
public void appendText(java.lang.StringBuilder result, TemplateEngineDataProvider dataProvider)
TemplateEntry
appendText
in interface TemplateEntry
result
- the StringBuilder
to append the text todataProvider
- the data provider from which information should be compiled to a stringpublic boolean isValid(TemplateEngineDataProvider dataProvider)
TemplateEntry
isValid
in interface TemplateEntry
dataProvider
- the data provider to checkpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean isSpecial()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object