protected Object eval ( DapVariable var , DapSequence seq , DataCursor record , CEAST expr ) throws DapException { switch ( expr . sort ) { case CONSTANT : return expr . value ; case SEGMENT : return fieldValue ( var , seq , record , expr . name ) ; case EXPR : Object lhs = eval ( var , seq , record , expr . lhs ) ; Object rhs = ( expr . rhs == null ? null : eval ( var , seq , record , expr . rhs ) ) ; if ( rhs != null ) switch ( expr . op ) { case LT : return compare ( lhs , rhs ) < 0 ; case LE : return compare ( lhs , rhs ) <= 0 ; case GT : return compare ( lhs , rhs ) > 0 ; case GE : return compare ( lhs , rhs ) >= 0 ; case EQ : return lhs . equals ( rhs ) ; case NEQ : return ! lhs . equals ( rhs ) ; case REQ : return lhs . toString ( ) . matches ( rhs . toString ( ) ) ; case AND : return ( ( Boolean ) lhs ) && ( ( Boolean ) rhs ) ; } else switch ( expr . op ) { case NOT : return ! ( ( Boolean ) lhs ) ; } } throw new DapException ( "Malformed Filter" ) ; }
Evaluate a filter with respect to a Sequence record . Assumes the filter has been canonicalized so that the lhs is a variable .