Пример #1
0
  @Override
  public final void accept(Context<?> ctx) {

    // If this is already a subquery, proceed
    if (ctx.subquery()) {
      ctx.keyword(quantifier.toSQL())
          .sql(" (")
          .formatIndentStart()
          .formatNewLine()
          .visit(delegate(ctx.configuration()))
          .formatIndentEnd()
          .formatNewLine()
          .sql(")");
    } else {
      ctx.keyword(quantifier.toSQL())
          .sql(" (")
          .subquery(true)
          .formatIndentStart()
          .formatNewLine()
          .visit(delegate(ctx.configuration()))
          .formatIndentEnd()
          .formatNewLine()
          .subquery(false)
          .sql(")");
    }
  }
Пример #2
0
 @Test
 public void testToString() {
   final Constant constant = Constant.create("emptyset");
   Assert.assertEquals("§emptyset", constant.toString());
   final Variable variable = Variable.create("var");
   Assert.assertEquals("$var", variable.toString());
   final Function function = Function.create("add", constant, variable);
   Assert.assertEquals("\\add(§emptyset,$var)", function.toString());
   final Attribute attribute = Attribute.create("element", function, constant, variable);
   Assert.assertEquals("%element(\\add(§emptyset,$var),§emptyset,$var)", attribute.toString());
   final Quantifier ex = Quantifier.create("exists", variable, attribute);
   Assert.assertEquals("*exists$var%element(\\add(§emptyset,$var),§emptyset,$var)", ex.toString());
   final Quantifier all = Quantifier.create("forall", variable, attribute);
   Assert.assertEquals(
       "*forall$var%element(\\add(§emptyset,$var),§emptyset,$var)", all.toString());
   final LogicalConnective connective = LogicalConnective.create("and", ex, all);
   Assert.assertEquals(
       "&and(*exists$var%element(\\add(§emptyset,$var),§emptyset,$var),*forall$var%element(\\add(§emptyset,$var),§emptyset,$var))",
       connective.toString());
 }