Examples of DefaultParser


Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    };

    StringReader reader = new StringReader(
        "${loop sort asc numberArray}${numberArray}${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("012345", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    };

    StringReader reader = new StringReader(
        "${loop sort desc numberArray}${numberArray}${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("543210", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    };

    StringReader reader = new StringReader(
        "${loop sort asc numberArray}${numberArray}${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("141015", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    };

    StringReader reader = new StringReader(
        "${loop sort asc numberArray}${numberArray}${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("*1*2", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

  public void nestedLoopTest() throws IOException {
   
    //outer field contains less elements than inner field
    StringReader reader = new StringReader("${loop}${loop}${outer}${inner}${/loop}${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0, 1}, new int[]{0, 1, 2}));
   
    Assert.assertEquals("000102101112", writer.toString());
   
    //outer field contains more elements than inner field
    reader = new StringReader("${loop}${loop}${outer}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0, 1, 2}, new int[]{0, 1}));
    Assert.assertEquals("000110112021", writer.toString());
       
    //inner and outer field have same length
    reader = new StringReader("${loop}${loop}${outer}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0, 1}, new int[]{2, 3}));
   
    Assert.assertEquals("02031213", writer.toString());
   
    //outer field is empty
    reader = new StringReader("${loop}${loop}${outer}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{}, new int[]{0, 1}));
   
    Assert.assertEquals("", writer.toString());
   
    //inner field is empty
    reader = new StringReader("${loop}${outer}${loop}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0,1}, new int[]{}));
   
    Assert.assertEquals("01", writer.toString());

    //inner field is empty, and no access to outer
    reader = new StringReader("${loop}*${loop}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0,1}, new int[]{}));

    Assert.assertEquals("**", writer.toString());
   
    //both fields are empty
    reader = new StringReader("${loop}${loop}${outer}${inner}${/loop}${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{}, new int[]{}));
   
    Assert.assertEquals("", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    StringReader reader = new StringReader(
        "${number}${if number = \"5\"}==5${else}!=5${/if}"
            + "${number2}${if number2 = \"5\"}==5${else}!=5${/if}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("5==51!=5", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    StringReader reader = new StringReader("${loop}" + "${loop}"
        + "${if outer = \"1\"}"
        + "${if inner = \"2\"}${outer}${inner}${/if}" + "${/if}"
        + "${/loop}" + "${/loop}");
    StringWriter writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0,1}, new int[]{0,1,2}));

    Assert.assertEquals("12", writer.toString());

    reader = new StringReader("${loop}" + "${loop}"
        + "${if outer = inner}same${/if}" + "${/loop}" + "${/loop}");
    writer = new StringWriter();
    new DefaultParser(reader, writer).perform(
        createOuterInnerDataFieldResolver(new int[]{0,1}, new int[]{0,1,2}));

    Assert.assertEquals("samesame", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${rdfs:comment}");
    StringWriter writer = new StringWriter();

    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("\"a resource\"", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${-rdfs:comment}");
    StringWriter writer = new StringWriter();

    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("<http://example.org/subject>", writer.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.templating.seedsnipe.simpleparser.DefaultParser

    });

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${rdfs:comment}");
    StringWriter writer = new StringWriter();

    new DefaultParser(reader, writer).perform(dataFieldResolver);

    Assert.assertEquals("VALUE:\"a resource\"", writer.toString());
  }
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.