Class ContextSwitchTemplate
- java.lang.Object
-
- org.openstreetmap.josm.tools.template_engine.ContextSwitchTemplate
-
- All Implemented Interfaces:
TemplateEntry
public class ContextSwitchTemplate extends Object implements TemplateEntry
The context switch offers possibility to use tags of referenced primitive when constructing primitive name.- Since:
- 4546
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ContextSwitchTemplate.AndSet
private static class
ContextSwitchTemplate.ChildSet
private static class
ContextSwitchTemplate.ContextProvider
private static class
ContextSwitchTemplate.OrSet
private static class
ContextSwitchTemplate.ParentSet
-
Field Summary
Fields Modifier and Type Field Description private ContextSwitchTemplate.ContextProvider
context
private static TemplateEngineDataProvider
EMPTY_PROVIDER
private TemplateEntry
template
-
Constructor Summary
Constructors Constructor Description ContextSwitchTemplate(SearchCompiler.Match match, TemplateEntry template, int searchExpressionPosition)
Constructs a newContextSwitchTemplate
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendText(StringBuilder result, TemplateEngineDataProvider dataProvider)
Execute this template by generating text for a given data provider.boolean
equals(Object obj)
int
hashCode()
boolean
isValid(TemplateEngineDataProvider dataProvider)
Check if this template is applicable to the given data provider.private static SearchCompiler.Match
transform(SearchCompiler.Match m, int searchExpressionPosition)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.tools.template_engine.TemplateEntry
getText
-
-
-
-
Field Detail
-
EMPTY_PROVIDER
private static final TemplateEngineDataProvider EMPTY_PROVIDER
-
context
private final ContextSwitchTemplate.ContextProvider context
-
template
private final TemplateEntry template
-
-
Constructor Detail
-
ContextSwitchTemplate
public ContextSwitchTemplate(SearchCompiler.Match match, TemplateEntry template, int searchExpressionPosition) throws ParseError
Constructs a newContextSwitchTemplate
.- Parameters:
match
- matchtemplate
- templatesearchExpressionPosition
- search expression position- Throws:
ParseError
- if a parse error occurs, or if the match transformation returns the same primitive
-
-
Method Detail
-
transform
private static SearchCompiler.Match transform(SearchCompiler.Match m, int searchExpressionPosition) throws ParseError
- Throws:
ParseError
-
appendText
public void appendText(StringBuilder result, TemplateEngineDataProvider dataProvider)
Description copied from interface:TemplateEntry
Execute this template by generating text for a given data provider.- Specified by:
appendText
in interfaceTemplateEntry
- Parameters:
result
- theStringBuilder
to 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:TemplateEntry
Check if this template is applicable to the given data provider.- Specified by:
isValid
in 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
-
-