Examples of Comparison


Examples of org.lealone.expression.Comparison

            return elsePart;
        }
        readIf("WHEN");
        Expression when = readExpression();
        if (left != null) {
            when = new Comparison(session, Comparison.EQUAL, left, when);
        }
        read("THEN");
        Expression then = readExpression();
        Expression elsePart = readWhen(left);
        Function function = Function.getFunction(session.getDatabase(), "CASEWHEN");
View Full Code Here

Examples of org.lealone.expression.Comparison

        addParameter(param);
        Expression comp;
        Expression col = expressions.get(columnId);
        col = col.getNonAliasExpression();
        if (col.isEverything(ExpressionVisitor.QUERY_COMPARABLE_VISITOR)) {
            comp = new Comparison(session, comparisonType, col, param);
        } else {
            // this condition will always evaluate to true, but need to
            // add the parameter, so it can be set later
            comp = new Comparison(session, Comparison.EQUAL_NULL_SAFE, param, param);
        }
        comp = comp.optimize(session);
        boolean addToCondition = true;
        if (isGroupQuery) {
            addToCondition = false;
View Full Code Here

Examples of org.modeshape.jcr.query.model.Comparison

        return new And(left, right);
    }

    protected Comparison like( DynamicOperand left,
                               StaticOperand right ) {
        return new Comparison(left, Operator.LIKE, right);
    }
View Full Code Here

Examples of org.modeshape.jcr.query.xpath.XPath.Comparison

    }

    protected Comparison comparison( Component left,
                                     Operator operator,
                                     Component right ) {
        return new Comparison(left, operator, right);
    }
View Full Code Here

Examples of org.teiid.language.Comparison

    }   
   
    @Override
    public List<?> translate(LanguageObject obj, ExecutionContext context) {
      if (obj instanceof Comparison) {
        Comparison compare = (Comparison)obj;
        if (compare.getLeftExpression().getType() == TypeFacility.RUNTIME_TYPES.BOOLEAN
            && compare.getLeftExpression() instanceof Function
            && compare.getRightExpression() instanceof Literal) {
          boolean isTrue = Boolean.TRUE.equals(((Literal)compare.getRightExpression()).getValue());
          if ((isTrue && compare.getOperator() == Operator.EQ) || (!isTrue && compare.getOperator() == Operator.NE)) {
            return Arrays.asList(compare.getLeftExpression());
          }
          if ((!isTrue && compare.getOperator() == Operator.EQ) || (isTrue && compare.getOperator() == Operator.NE)) {
            return Arrays.asList("NOT ", compare.getLeftExpression()); //$NON-NLS-1$
          }
        }
      } else if (obj instanceof Not) {
        Not not = (Not)obj;
        return Arrays.asList("NOT ", not.getCriteria()); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.language.Comparison

   
    public void test2() {
        NamedTable g1 = new NamedTable("g1", null, null); //$NON-NLS-1$
        ColumnReference e1 = new ColumnReference(g1, "e1", null, String.class); //$NON-NLS-1$
        ColumnReference e2 = new ColumnReference(g1, "e2", null, String.class); //$NON-NLS-1$
        Comparison cc = new Comparison(e1, e2, Operator.EQ);
       
        helpTestElementsUsedByGroups(cc, new String[] {"g1.e1", "g1.e2"}, new String[] {"g1"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
View Full Code Here

Examples of org.teiid.language.Comparison

      Literal literal = (Literal)startIndex; 
      if (literal.getValue() instanceof Integer && ((Integer)literal.getValue() < 1)) {
        literal.setValue(1);
      }
    } else {
      Comparison whenExpr = langFactory.createCompareCriteria(
          Operator.LT,
          startIndex,
          langFactory.createLiteral(1, Integer.class)
        );
      Literal thenExpr = langFactory.createLiteral(1, Integer.class);
View Full Code Here

Examples of org.teiid.language.Comparison

    public static Comparison example(int operator, int leftVal, int rightVal) throws Exception {
        return TstLanguageBridgeFactory.factory.translate(helpExample(operator, leftVal, rightVal));
    }

    public void testGetLeftExpression() throws Exception {
        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
        assertNotNull(impl.getLeftExpression());
        assertTrue(impl.getLeftExpression() instanceof Literal);
        assertEquals(new Integer(200), ((Literal)impl.getLeftExpression()).getValue());
    }
View Full Code Here

Examples of org.teiid.language.Comparison

        assertTrue(impl.getLeftExpression() instanceof Literal);
        assertEquals(new Integer(200), ((Literal)impl.getLeftExpression()).getValue());
    }

    public void testGetRightExpression() throws Exception {
        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
        assertNotNull(impl.getRightExpression());
        assertTrue(impl.getRightExpression() instanceof Literal);
        assertEquals(new Integer(100), ((Literal)impl.getRightExpression()).getValue());
    }
View Full Code Here

Examples of org.teiid.language.Comparison

    }
    if (!(criteria instanceof Comparison)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotSimpleError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Comparison compareCriteria = (Comparison)criteria; 
    if (compareCriteria.getOperator() != Operator.EQ) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotEqualsError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression leftExpr = compareCriteria.getLeftExpression();
    if (!(leftExpr instanceof ColumnReference)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaLHSNotElementError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    // call utility method to get NameInSource/Name for element
    String nameLeftExpr = getNameFromElement((ColumnReference)leftExpr);
    if (!(nameLeftExpr.toUpperCase().equals("DN"))) {   //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaSrcColumnError",nameLeftExpr); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression rightExpr = compareCriteria.getRightExpression();
    if (!(rightExpr instanceof Literal)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaRHSNotLiteralError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Object valueRightExpr = ((Literal)rightExpr).getValue();
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.