dods.dap.Server
Class RelOpClause

java.lang.Object
  extended by dods.dap.Server.AbstractClause
      extended by dods.dap.Server.RelOpClause
All Implemented Interfaces:
Clause, TopLevelClause

public class RelOpClause
extends AbstractClause
implements TopLevelClause

Represents a clause which compares subclauses, using one of the relative operators supported by the Operator class.

Author:
joew
See Also:
Operator, ClauseFactory

Field Summary
protected  SubClause lhs
           
protected  int operator
           
protected  List rhs
           
protected  boolean value
           
 
Fields inherited from class dods.dap.Server.AbstractClause
children, constant, defined
 
Constructor Summary
protected RelOpClause(int operator, SubClause lhs, List rhs)
          Creates a new RelOpClause.
 
Method Summary
 boolean evaluate()
          Evaluates the clause, first calling evaluate() on any sub-clauses it contains.
 SubClause getLHS()
          Returns a SubClause representing the right-hand side of the comparison.
 int getOperator()
          Returns the type of comparison
 List getRHS()
          Returns a list of SubClauses representing the right-hand side of the comparison.
 boolean getValue()
          Returns the current value of the clause.
 String toString()
          Prints the original string representation of this clause.
 
Methods inherited from class dods.dap.Server.AbstractClause
getChildren, isConstant, isDefined
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dods.dap.Server.Clause
getChildren, isConstant, isDefined
 

Field Detail

value

protected boolean value

operator

protected int operator

lhs

protected SubClause lhs

rhs

protected List rhs
Constructor Detail

RelOpClause

protected RelOpClause(int operator,
                      SubClause lhs,
                      List rhs)
               throws SDODSException
Creates a new RelOpClause. If the lhs and all the elements of the rhs are constant, the RelOpClause will be flagged as constant, and evaluated immediately.

Parameters:
operator - The operator invoked by the clause
lhs - The left-hand side of the comparison.
rhs - A list of SubClauses representing the right-hand side of the comparison.
Throws:
SDODSException - Thrown if the clause is constant, but the attempt to evaluate it fails.
Method Detail

getValue

public boolean getValue()
Description copied from interface: TopLevelClause
Returns the current value of the clause. The value of non-constant Clauses is undefined until the evaluate() method has been called.

Specified by:
getValue in interface TopLevelClause

evaluate

public boolean evaluate()
                 throws SDODSException
Description copied from interface: TopLevelClause
Evaluates the clause, first calling evaluate() on any sub-clauses it contains. Implementations of this method should flag the clause as "defined" if the evaluation is successful.

Specified by:
evaluate in interface TopLevelClause
Throws:
SDODSException - Thrown if the evaluation fails for any reason.

getLHS

public SubClause getLHS()
Returns a SubClause representing the right-hand side of the comparison.


getRHS

public List getRHS()
Returns a list of SubClauses representing the right-hand side of the comparison.


getOperator

public int getOperator()
Returns the type of comparison

See Also:
ExprParserConstants

toString

public String toString()
Prints the original string representation of this clause. For use in debugging.

Overrides:
toString in class Object