Package org.apache.clerezza.templating.seedsnipe.datastructure

Examples of org.apache.clerezza.templating.seedsnipe.datastructure.DataFieldResolver


*/
public class SimpleTemplatingTest {

  @Test
  public void fieldTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {

      @Override
      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (fieldName.equals("number")) {
View Full Code Here


        "5<!-- could not resolve: foo "));
  }

  @Test
  public void loopTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      private int[] numberArray = { 0, 1, 2, 3, 4, 5 };

      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (arrayPos[0] == numberArray.length) {
View Full Code Here

    Assert.assertEquals("012345", writer.toString());
  }

  @Test
  public void ifInloopTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      private int[] numberArray = { 0, 1, 2, 3, 4, 5 };

      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (arrayPos[0] == numberArray.length) {
View Full Code Here

    Assert.assertEquals("001122334455", writer9.toString());
  }

  @Test
  public void sortedLoopTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      private int[] numberArray = { 4, 1, 5, 3, 0, 2 };

      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (arrayPos[0] == numberArray.length) {
View Full Code Here

    Assert.assertEquals("012345", writer.toString());
  }

  @Test
  public void sortDescendingLoopTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      private int[] numberArray = { 4, 1, 5, 3, 0, 2 };

      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (arrayPos[0] == numberArray.length) {
View Full Code Here

  }

  // it should sort by the value of the field not its string-representation
  @Test
  public void sortedLoopNonStringTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      private int[] numberArray = { 4, 1, 10, 15 };

      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
        if (arrayPos[0] == numberArray.length) {
View Full Code Here

    Assert.assertEquals("141015", writer.toString());
  }

  @Test
  public void sortNotComparable() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      Object value1 = new Object() {
        @Override
        public String toString() {
          return "*1";
        }
 
View Full Code Here

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

  @Test
  public void ifTest() throws IOException {
    DataFieldResolver dataFieldResolver = new DataFieldResolver() {
      public Object resolveAsObject(String fieldName, int[] arrayPos) {
        if (fieldName.equals("number"))
          return 5;
        else
          return 1;
View Full Code Here

  /*
  Creates a DataFieldResolver for nested loops.
  The fieldname of the outer loop is "outer" and the fieldname of the inner loop is "inner".
  */
  private DataFieldResolver createOuterInnerDataFieldResolver(final int[] outer, final int[] inner) {
    return new DataFieldResolver() {
      public Object resolveAsObject(String fieldName, int[] arrayPos)
          throws FieldIndexOutOfBoundsException {
       
        if(arrayPos[0] == outer.length) {
          throw new FieldIndexOutOfBoundsException(fieldName, arrayPos, 0);         
View Full Code Here

    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    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);
View Full Code Here

TOP

Related Classes of org.apache.clerezza.templating.seedsnipe.datastructure.DataFieldResolver

Copyright © 2018 www.massapicom. 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.