Examples of DottedExpression


Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

public class CompareExpressionParserTest {

  @Test
  public void testVisitSimpleDottedExpression() throws IOException {
    String sText = "bytes";
    DottedExpression expr = ExpressionParser.parse(sText);
    PropertyExpressionVisitor visitor = PropertyExpressionVisitor.of("titi", "toto");
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(true));
    visitor = PropertyExpressionVisitor.of("titi", "titi");
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(false));
  }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

  }

  @Test
  public void testVisitMultipleDottedExpression() throws IOException {
    String sText = "derived.name";
    DottedExpression expr = ExpressionParser.parse(sText);
    Model m1 = new Model("titi");
    m1.setDerived(new Model("titi"));
    Model m2 = new Model("titi");
    m2.setDerived(new Model("titi"));
    PropertyExpressionVisitor visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(false));
    m2.setDerived(new Model("toto"));
    visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(true));
  }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

  }

  @Test
  public void testVisitArrayIntegerExpression() throws IOException {
    String sText = "children[0].name";
    DottedExpression expr = ExpressionParser.parse(sText);
    Model m1 = new Model("titi");
    Model m2 = new Model("titi");
    PropertyExpressionVisitor visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(false));
    m1.setChildren(Lists.newArrayList(new Model("tutu")));
    visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(true));
  }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

  }

  @Test
  public void testVisitArrayStarExpression() throws IOException {
    String sText = "children[*].name";
    DottedExpression expr = ExpressionParser.parse(sText);
    Model m1 = new Model("titi");
    m1.setChildren(Lists.newArrayList(new Model("tutu")));
    Model m2 = CompareTools.deepCopy(m1);
    PropertyExpressionVisitor visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(false));
    m2.getChildren().get(0).setName("toto");
    visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(true));
    m2.getChildren().get(0).setName("tutu");
    visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(false));
    m2.getChildren().add(new Model("toto"));
    visitor = PropertyExpressionVisitor.of(m1, m2);
    expr.accept(visitor);
    assertThat(visitor.getGraph().isChanged(), CoreMatchers.equalTo(true));
  }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

    long moyToString = 0;
    String sText = "userTruc.maTable[variable.attribute == false | (toto > 18 & userTruc[*].family in [\"toto\", \"titi\"])].tableau[length(texte)].name";
    Stopwatch sw = new Stopwatch();
    for (int i = 0; i < MAX_LOOP; i++) {
      sw.reset().start();
      DottedExpression expr = ExpressionParser.parse(sText);
      if (i != 0) {
        moyParsing += sw.elapsedTime(TimeUnit.MICROSECONDS);
      }
//      System.out.print("Parsing [" + i + "] : " + sw.elapsedTime(TimeUnit.MICROSECONDS) + " mus");
      sw.reset().start();
      exprTs.add(expr.toString());
      if (i != 0) {
        moyToString += sw.elapsedTime(TimeUnit.MICROSECONDS);
      }
//      System.out.println(" / toString : " + sw.elapsedTime(TimeUnit.MICROSECONDS) + " ms ");
    }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

    stream.ignoreBlanks();
    String sVarName = stream.readIdentifier();
    if (sVarName == null) {
      throw new ParsingException(stream, stream.syntaxError("dotted expression expected"));
    }
    DottedExpression expr = new DottedExpression(sVarName);
    stream.ignoreBlanks();
    if (stream.isEqualTo('[')) {
      Expression indexExpr = parseExpression(stream);
      stream.ignoreBlanks();
      if (!stream.isEqualTo(']')) {
        throw new ParsingException(stream, stream.syntaxError("']' expected"));
      }
      expr.setIndex(indexExpr);
    }
    stream.ignoreBlanks();
    if (stream.isEqualTo('.')) {
      DottedExpression nextExpr = parseDottedExpression(stream);
      expr.setNext(nextExpr);
    }
    return expr;
  }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

      } else {
        Double dValue = stream.readDouble();
        if (dValue != null) {
          return new DoubleLiteral(dValue);
        } else {
          DottedExpression dotted = parseDottedExpression(stream);
          if (dotted.getIndex() == null && dotted.getNext() == null) {
            if (dotted.getVariableName().equals("true") || dotted.getVariableName().equals("false")) {
              return new BooleanLiteral(dotted.getVariableName());
            }
          }
          if (stream.isEqualTo('(')) {
            return parseIntermediateFunctionCall(stream, dotted.getVariableName());
          }
          return dotted;
        }
      }
    }
View Full Code Here

Examples of org.elegant.aash.comparator.parsing.expr.DottedExpression

  public static void main(String[] args) {
    String sText = "userTruc.maTable[variable.attribute == false | (toto > 18 & userTruc[*].family in [\"toto\", \"titi\"])].tableau[length(texte)].name";
    ParsingTools stream = new ParsingTools(sText);
    try {
      System.out.println(sText);
      DottedExpression expr = parseDottedExpression(stream);
      System.out.println(expr.toString());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
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.