001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.tools.template_engine; 003 004 import org.openstreetmap.josm.actions.search.SearchCompiler.Match; 005 006 public class SearchExpressionCondition implements TemplateEntry { 007 008 private final Match condition; 009 private final TemplateEntry text; 010 011 public SearchExpressionCondition(Match condition, TemplateEntry text) { 012 this.condition = condition; 013 this.text = text; 014 } 015 016 @Override 017 public void appendText(StringBuilder result, TemplateEngineDataProvider dataProvider) { 018 text.appendText(result, dataProvider); 019 } 020 021 @Override 022 public boolean isValid(TemplateEngineDataProvider dataProvider) { 023 return dataProvider.evaluateCondition(condition); 024 } 025 026 @Override 027 public String toString() { 028 return condition.toString() + " '" + text.toString() + "'"; 029 } 030 031 }