Examples of Substitutions


Examples of org.apache.cocoon.template.expression.Substitutions

            String uri = attrs.getURI(i);
            String local = attrs.getLocalName(i);
            String qname = attrs.getQName(i);
            String type = attrs.getType(i);
            String value = attrs.getValue(i);
            Substitutions substitutions = new Substitutions(parsingContext.getStringTemplateParser(), getLocation(), value);
            if (substitutions.hasSubstitutions()) {
                getAttributeEvents().add(
                        new SubstituteAttribute(uri, local, qname, type,
                                substitutions));
            } else {
                getAttributeEvents().add(
View Full Code Here

Examples of org.apache.cocoon.template.expression.Substitutions

    public TextEvent(ParsingContext parsingContext, Locator location, char[] chars, int start, int length)
            throws SAXException {
        super(location);
        this.raw = new char[length];
        System.arraycopy(chars, start, this.raw, 0, length);
        this.substitutions = new Substitutions(parsingContext.getStringTemplateParser(), getLocation(), chars, start, length);
    }
View Full Code Here

Examples of org.apache.cocoon.template.expression.Substitutions

        this.originalExpr = expression;
        try {
            if (stringTemplateParser instanceof LegacySitemapStringTemplateParser)
                this.substitutions = new LegacySubstitutions((LegacySitemapStringTemplateParser) stringTemplateParser, null, expression);
            else
                this.substitutions = new Substitutions(stringTemplateParser, null, expression);
        } catch (Exception e) {
            throw new PatternException(e);
        }
    }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void testContentSubstitution() throws Exception {
    String xml
        = "<Content type=\"html\">Hello, __MSG_world__ __MODULE_ID__</Content>";

    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Type.MESSAGE, "world", "foo __UP_planet____BIDI_START_EDGE__");
    substituter.addSubstitution(Type.USER_PREF, "planet", "Earth");
    substituter.addSubstitution(Type.BIDI, "START_EDGE", "right");
    substituter.addSubstitution(Type.MODULE, "ID", "3");

    View view = new View("test",
        Arrays.asList(XmlUtil.parse(xml)), SPEC_URL).substitute(substituter);
    assertEquals("Hello, foo Earthright 3", view.getContent());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void testHrefSubstitution() throws Exception {
    String href = "http://__MSG_domain__/__MODULE_ID__?dir=__BIDI_DIR__";
    String xml = "<Content type=\"url\" href=\"" + href + "\"/>";

    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Type.MESSAGE, "domain", "__UP_subDomain__.example.org");
    substituter.addSubstitution(Type.USER_PREF, "subDomain", "up");
    substituter.addSubstitution(Type.BIDI, "DIR", "rtl");
    substituter.addSubstitution(Type.MODULE, "ID", "123");

    View view = new View("test",
        Arrays.asList(XmlUtil.parse(xml)), SPEC_URL).substitute(substituter);
    assertEquals("http://up.example.org/123?dir=rtl",
                 view.getHref().toString());
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void testHrefRelativeSubstitution() throws Exception {
    String href = "__MSG_foo__";
    String xml = "<Content type=\"url\" href=\"" + href + "\"/>";

    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Type.MESSAGE, "foo", "/bar");

    View view = new View("test", Arrays.asList(XmlUtil.parse(xml)), SPEC_URL);
    view = view.substitute(substituter);
    assertEquals(SPEC_URL.resolve(Uri.parse("/bar")), view.getHref());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  public void authAttributes() throws Exception {
    String xml = "<Content type='html' sign_owner='false' sign_viewer='false' foo='bar' " +
                 "yo='momma' sub='__MSG_view__'/>";

    View view = new View("test", Arrays.asList(XmlUtil.parse(xml)), SPEC_URL);
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "view", "stuff");
    View substituted = view.substitute(substituter);
    assertEquals("bar", substituted.getAttributes().get("foo"));
    assertEquals("momma", substituted.getAttributes().get("yo"));
    assertEquals("stuff", substituted.getAttributes().get("sub"));
    assertFalse("sign_owner parsed incorrectly.", view.isSignOwner());
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

                 "  <Link rel='" + link1Rel + "' href='" + link1Href + "'/>" +
                 "  <Link rel='" + link2Rel + "' href='" + link2Href + "'/>" +
                 "</ModulePrefs>";

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL)
        .substitute(new Substitutions());

    assertEquals(link1Href, prefs.getLinks().get(link1Rel).getHref());
    assertEquals(SPEC_URL.resolve(link2Href), prefs.getLinks().get(link2Rel).getHref());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

    String rel = "foo-bar";
    String linkHref = "http://example.org/link.html";
    String preHref = "http://example.org/preload.html";

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL);
    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);

    assertEquals(title, prefs.getTitle());
    assertEquals(icon, prefs.getIcons().get(0).getContent());
    assertEquals(rel, prefs.getLinks().get(rel).getRel());
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

      // OK
    }
  }

  public void testSubstitutions() throws Exception {
    Substitutions substituter = new Substitutions();
    String title = "Hello, World!";
    String content = "Goodbye, world :(";
    String xml = "<Module>" +
                 "<ModulePrefs title=\"__UP_title__\"/>" +
                 "<Content type=\"html\">__MSG_content__</Content>" +
                 "</Module>";
    substituter.addSubstitution(Type.USER_PREF, "title", title);
    substituter.addSubstitution(Type.MESSAGE, "content", content);

    GadgetSpec baseSpec = new GadgetSpec(SPEC_URL, xml);
    baseSpec.setAttribute("foo", 100);
    baseSpec.setAttribute("bar", "baz");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.