Search in sources :

Example 91 with Map

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());
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 92 with Map

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());
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 93 with Map

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());
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 94 with Map

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());
        }
    }
}
Also used : TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 95 with Map

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);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) NullWriter(org.codehaus.groovy.control.io.NullWriter) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Aggregations

Map (java.util.Map)15646 HashMap (java.util.HashMap)9529 ArrayList (java.util.ArrayList)3619 List (java.util.List)2988 Test (org.junit.Test)2558 Set (java.util.Set)1837 HashSet (java.util.HashSet)1646 IOException (java.io.IOException)1486 Iterator (java.util.Iterator)1307 LinkedHashMap (java.util.LinkedHashMap)1284 TreeMap (java.util.TreeMap)1022 ImmutableMap (com.google.common.collect.ImmutableMap)879 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)729 File (java.io.File)662 Collection (java.util.Collection)576 Collectors (java.util.stream.Collectors)436 ConcurrentMap (java.util.concurrent.ConcurrentMap)375 LinkedList (java.util.LinkedList)333 SSOException (com.iplanet.sso.SSOException)294 Collections (java.util.Collections)288