Class Variable
- java.lang.Object
-
- org.openstreetmap.josm.tools.template_engine.Variable
-
- All Implemented Interfaces:
TemplateEntry
public class Variable extends java.lang.Object implements TemplateEntry
TemplateEntrythat 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)).
-
-
Field Summary
Fields Modifier and Type Field Description private booleanspecialprivate static java.lang.StringSPECIAL_VALUE_EVERYTHINGprivate static java.lang.StringSPECIAL_VARIABLE_PREFIXprivate java.lang.StringvariableName
-
Constructor Summary
Constructors Constructor Description Variable(java.lang.String variableName)Constructs a newVariable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendText(java.lang.StringBuilder result, TemplateEngineDataProvider dataProvider)Execute this template by generating text for a given data provider.booleanequals(java.lang.Object obj)inthashCode()booleanisSpecial()Check if this variable is special.booleanisValid(TemplateEngineDataProvider dataProvider)Check if this template is applicable to the given data provider.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.tools.template_engine.TemplateEntry
getText
-
-
-
-
Field Detail
-
SPECIAL_VARIABLE_PREFIX
private static final java.lang.String SPECIAL_VARIABLE_PREFIX
- See Also:
- Constant Field Values
-
SPECIAL_VALUE_EVERYTHING
private static final java.lang.String SPECIAL_VALUE_EVERYTHING
- See Also:
- Constant Field Values
-
variableName
private final java.lang.String variableName
-
special
private final boolean special
-
-
Constructor Detail
-
Variable
public Variable(java.lang.String variableName)
Constructs a newVariable.- Parameters:
variableName- the variable name (i.e. the key in the data provider key-value mapping); will be considered "special" if the variable name starts withSPECIAL_VARIABLE_PREFIX
-
-
Method Detail
-
appendText
public void appendText(java.lang.StringBuilder result, TemplateEngineDataProvider dataProvider)
Description copied from interface:TemplateEntryExecute this template by generating text for a given data provider.- Specified by:
appendTextin interfaceTemplateEntry- Parameters:
result- theStringBuilderto append the text todataProvider- the data provider from which information should be compiled to a string
-
isValid
public boolean isValid(TemplateEngineDataProvider dataProvider)
Description copied from interface:TemplateEntryCheck if this template is applicable to the given data provider.- Specified by:
isValidin interfaceTemplateEntry- Parameters:
dataProvider- the data provider to check- Returns:
- true if all conditions are fulfilled to apply the template (for instance all required key=value mappings are present), false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isSpecial
public boolean isSpecial()
Check if this variable is special.- Returns:
- true if this variable is special
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-