use of java.util.Map in project groovy by apache.
the class TemplateTest method testBinding.
public void testBinding() throws CompilationFailedException, ClassNotFoundException, IOException {
Map binding = new HashMap();
binding.put("sam", "pullara");
Template template1 = new SimpleTemplateEngine().createTemplate("<%= sam %><% print sam %>");
assertEquals("pullarapullara", template1.make(binding).toString());
Template template2 = new GStringTemplateEngine().createTemplate("<%= sam %><% out << sam %>");
assertEquals("pullarapullara", template2.make(binding).toString());
Template template3 = new GStringTemplateEngine().createTemplate("<%= sam + \" \" + sam %><% out << sam %>");
assertEquals("pullara pullarapullara", template3.make(binding).toString());
}
use of java.util.Map in project groovy by apache.
the class XmlTemplateEngineTest method testQuotes.
public void testQuotes() throws Exception {
Map binding = new HashMap();
binding.put("Christian", "Stein");
XmlTemplateEngine xmlTemplateEngine = new XmlTemplateEngine();
String xmlScript = "<!-- Just a comment. -->\n" + "<xml xmlns:mygsp=\"http://groovy.codehaus.org/2005/gsp\">" + " ${Christian + \" \" + Christian}" + " <mygsp:expression>Christian + \" \" + Christian</mygsp:expression>" + " <mygsp:scriptlet>println Christian</mygsp:scriptlet>" + "</xml>";
String xmlResult = "<xml>\n" + " Stein Stein\n" + xmlTemplateEngine.getIndentation() + "Stein Stein\n" + "Stein" + System.getProperty("line.separator") + "</xml>\n";
Template template = xmlTemplateEngine.createTemplate(xmlScript);
assertEquals(xmlResult, template.make(binding).toString());
}
use of java.util.Map in project groovy by apache.
the class XmlTemplateEngineTest method testBinding.
public void testBinding() throws Exception {
Map binding = new HashMap();
binding.put("Christian", "Stein");
XmlTemplateEngine xmlTemplateEngine = new XmlTemplateEngine();
String xmlScript = "<!-- Just a comment. -->\n" + "<xml xmlns:gsp=\"http://groovy.codehaus.org/2005/gsp\">" + " ${Christian}" + " <gsp:expression>Christian</gsp:expression>" + " <gsp:scriptlet>println Christian</gsp:scriptlet>" + "</xml>";
String xmlResult = "<xml>\n" + " Stein\n" + xmlTemplateEngine.getIndentation() + "Stein\n" + "Stein" + System.getProperty("line.separator") + "</xml>\n";
Template template = xmlTemplateEngine.createTemplate(xmlScript);
assertEquals(xmlResult, template.make(binding).toString());
}
use of java.util.Map in project groovy by apache.
the class BindPath method updateLocalSyntheticProperties.
public synchronized void updateLocalSyntheticProperties(Map<String, TriggerBinding> synthetics) {
localSynthetics = null;
String endName = "#" + propertyName;
for (Map.Entry<String, TriggerBinding> syntheticEntry : synthetics.entrySet()) {
if (syntheticEntry.getKey().endsWith(endName)) {
if (localSynthetics == null) {
localSynthetics = new TreeMap();
}
localSynthetics.put(syntheticEntry.getKey(), syntheticEntry.getValue());
}
}
}
use of java.util.Map in project groovy by apache.
the class BaseTemplate method writeAttributes.
private void writeAttributes(final Map<?, ?> attributes) throws IOException {
if (attributes == null) {
return;
}
final Writer wrt = out;
for (Map.Entry entry : attributes.entrySet()) {
wrt.write(' ');
String attName = entry.getKey().toString();
String value = entry.getValue() == null ? "" : entry.getValue().toString();
writeAttribute(attName, value);
}
}
Aggregations