Package org.apache.cayenne.exp

Examples of org.apache.cayenne.exp.Expression.evaluate()


    public void testEvaluateADD() throws Exception {
        Expression add = new ASTAdd(new Object[] {
                new Integer(1), new Double(5.5)
        });
        assertEquals(6.5, ((Number) add.evaluate(null)).doubleValue(), 0.0001);
    }

    public void testEvaluateSubtract() throws Exception {
        Expression subtract = new ASTSubtract(new Object[] {
                new Integer(1), new Double(0.1), new Double(0.2)
View Full Code Here


    public void testEvaluateSubtract() throws Exception {
        Expression subtract = new ASTSubtract(new Object[] {
                new Integer(1), new Double(0.1), new Double(0.2)
        });
        assertEquals(0.7, ((Number) subtract.evaluate(null)).doubleValue(), 0.0001);
    }

    public void testEvaluateMultiply() throws Exception {
        Expression multiply = new ASTMultiply(new Object[] {
                new Integer(2), new Double(3.5)
View Full Code Here

    public void testEvaluateMultiply() throws Exception {
        Expression multiply = new ASTMultiply(new Object[] {
                new Integer(2), new Double(3.5)
        });
        assertEquals(7, ((Number) multiply.evaluate(null)).doubleValue(), 0.0001);
    }

    public void testEvaluateDivide() throws Exception {
        Expression divide = new ASTDivide(new Object[] {
                new BigDecimal("7.0"), new BigDecimal("2.0")
View Full Code Here

    public void testEvaluateDivide() throws Exception {
        Expression divide = new ASTDivide(new Object[] {
                new BigDecimal("7.0"), new BigDecimal("2.0")
        });
        assertEquals(3.5, ((Number) divide.evaluate(null)).doubleValue(), 0.0001);
    }

    public void testEvaluateNegate() throws Exception {
        assertEquals(-3, ((Number) new ASTNegate(new Integer(3)).evaluate(null))
                .intValue());
View Full Code Here

    public int compare(Object o1, Object o2) {
        Expression exp = getSortSpec();
        Object value1 = null;
        Object value2 = null;
        try {
            value1 = exp.evaluate(o1);
        }
        catch (ExpressionException e) {
            if (pathExceptionSuppressed
                    && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) {
                // do nothing, we expect this
View Full Code Here

                throw e;
            }
        }

        try {
            value2 = exp.evaluate(o2);
        }
        catch (ExpressionException e) {
            if (pathExceptionSuppressed
                    && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) {
                // do nothing, we expect this
View Full Code Here

        Expression e = Expression.fromString("db:paintingArray.PAINTING_TITLE");

        ObjEntity ae = getDomain().getEntityResolver().lookupObjEntity(Artist.class);
        DbEntity ade = ae.getDbEntity();

        Object objTarget = e.evaluate(ae);
        assertTrue(objTarget instanceof DbAttribute);

        Object dbTarget = e.evaluate(ade);
        assertTrue(dbTarget instanceof DbAttribute);
    }
View Full Code Here

        DbEntity ade = ae.getDbEntity();

        Object objTarget = e.evaluate(ae);
        assertTrue(objTarget instanceof DbAttribute);

        Object dbTarget = e.evaluate(ade);
        assertTrue(dbTarget instanceof DbAttribute);
    }
   
    public void testEvaluateEQUAL_TOBigDecimal() throws Exception {
        BigDecimal bd1 = new BigDecimal("2.0");
View Full Code Here

    public static class INTrimmer implements Transformer {

        public Expression trimmedInExpression(Expression exp, int maxInSize) {
            Expression list = (Expression) exp.getOperand(1);
            Object[] objects = (Object[]) list.evaluate(null);

            if (objects.length <= maxInSize) {
                return exp;
            }
View Full Code Here

    public int compare(Object o1, Object o2) {
        Expression exp = getSortSpec();
    Object value1 = null;
    Object value2 = null;
    try {
          value1 = exp.evaluate(o1);
    } catch (ExpressionException e) {
      if (pathExceptionSuppressed && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) {
        //do nothing, we expect this
      } else {
        //re-throw
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.