Examples of ConditionalExpression


Examples of com.google.minijoe.compiler.ast.ConditionalExpression

    if (nextToken == Token.OPERATOR_CONDITIONAL) {
      readToken(Token.OPERATOR_CONDITIONAL);
      Expression trueExpression = parseAssignmentExpression(inFlag);
      readToken(Token.OPERATOR_COLON);
      Expression falseExpression = parseAssignmentExpression(inFlag);
      return new ConditionalExpression(expression, trueExpression, falseExpression);
    } else {
      return expression;
    }
  }
View Full Code Here

Examples of com.google.minijoe.compiler.ast.ConditionalExpression

  }

  public void testConditionalExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new ConditionalExpression(
                new BinaryOperatorExpression(
                    new NumberLiteral(1.0),
                    new NumberLiteral(0.0),
                    Token.OPERATOR_EQUALEQUAL
                ),
                new IncrementExpression(
                    new Identifier("foo"), 1, true
                ),
                new IncrementExpression(
                    new Identifier("bar"), 1, true
                )
            )
        ),
        "1 == 0 ? foo ++ : bar ++;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ConditionalExpression(
                new Identifier("foo"),
                new ConditionalExpression(
                    new Identifier("a"),
                    new Identifier("b"),
                    new Identifier("c")
                ),
                new ConditionalExpression(
                    new Identifier("x"),
                    new Identifier("y"),
                    new Identifier("z")
                )
            )
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

    }

    @Nonnull
    public SoqlQueryBuilder setWhereClause(@Nullable final String whereClause)
    {
        this.whereClause = new ConditionalExpression(whereClause);
        return this;
    }
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

        Soda2Consumer   consumer = createConsumer();

        //  Run an equality filter on a floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "=to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();
        final List<Nomination>  results = consumer.query(NOMINATION_DATA_SET, query, Nomination.LIST_TYPE);


        // Verify results against known values.
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");
        for (Nomination n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate());
        }

        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ ">to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();
        final List<Nomination>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, Nomination.LIST_TYPE);


        //  Verify results all come after the test date
        for (Nomination n: resultsGreater) {
            TestCase.assertTrue(n.getNominationDate().after(d));
        }

        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "<to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, Nomination.LIST_TYPE);

        // Verify results all come before the test date
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "=to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  results = consumer.query(NOMINATION_DATA_SET, query, NominationWithJoda.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (NominationWithJoda n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertTrue(n.getNominationDate().toDateTime(DateTimeZone.getDefault()).toDate().equals(d));
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ ">to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsGreater) {
            TestCase.assertTrue(n.getNominationDate().toDateTime(DateTimeZone.getDefault()).isAfter(d.getTime()));
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "<to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsLesser) {
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "=to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  results = consumer.query(NOMINATION_DATA_SET, query, Nomination.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (Nomination n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate());
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ ">to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, Nomination.LIST_TYPE);

        for (Nomination n: resultsGreater) {
            if (n.getConfirmationVoteDate() != null) {
                TestCase.assertTrue(d.before(n.getConfirmationVoteDate()));
            }
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "<to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, Nomination.LIST_TYPE);

        for (Nomination n: resultsLesser) {
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "=to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  results = consumer.query(NOMINATION_DATA_SET, query, NominationWithJoda.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (NominationWithJoda n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate().toDate());
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ ">to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsGreater) {
            if (n.getConfirmationVoteDate() != null) {
                TestCase.assertTrue(d.before(n.getConfirmationVoteDate().toDate()));
            }
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "<to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsLesser) {
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

    private void executeSimpleQuery(final HttpLowLevel connection, final String dataset) throws LongRunningQueryException, SodaError, InterruptedException
    {

        //Create a query that should return a single result
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression("primary_naics=325510"))
                .build();

        final Soda2Consumer   soda2Consumer = new Soda2Consumer(connection);

        //
View Full Code Here

Examples of com.socrata.model.soql.ConditionalExpression

    private void executeSimpleQuery(final HttpLowLevel connection, final String dataset) throws LongRunningQueryException, SodaError, InterruptedException
    {

        //Create a query that should return a single result
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression("primary_naics=325510"))
                .build();

        final Soda2Consumer soda2Consumer = new Soda2Consumer(connection);

        //
View Full Code Here

Examples of com.stuffwithstuff.bantam.expressions.ConditionalExpression

  public Expression parse(Parser parser, Expression left, Token token) {
    Expression thenArm = parser.parseExpression();
    parser.consume(TokenType.COLON);
    Expression elseArm = parser.parseExpression(Precedence.CONDITIONAL - 1);
   
    return new ConditionalExpression(left, thenArm, elseArm);
  }
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.