sdr 0.7

net.cscott.sdr.calls
Class Predicate

java.lang.Object
  extended by net.cscott.sdr.calls.ExprFunc<Boolean>
      extended by net.cscott.sdr.calls.Predicate

public abstract class Predicate
extends ExprFunc<Boolean>

A Predicate is a boolean test on the current formation and dance state, or else an operator on such boolean tests. For example, there are simple predicates such as "PROGRAM AT LEAST(foo)" which takes as an argument some dance program foo, as well as "and" and "or" predicates which combine other predicates to yield a boolean result. The Expr object in the call tree represents the unevaluated arguments of a Predicate application.

Version:
$Id: Predicate.java,v 1.3 2006-10-17 16:29:01 cananian Exp $
Author:
C. Scott Ananian

Nested Class Summary
 
Nested classes/interfaces inherited from class net.cscott.sdr.calls.ExprFunc
ExprFunc.EvaluationException
 
Constructor Summary
Predicate()
           
 
Method Summary
 boolean equals(Object o)
           
 Boolean evaluate(Class<? super Boolean> type, DanceState ds, List<Expr> args)
          Perform the operation of the ExprFunc on the given list of arguments args, yielding a value of the specified type.
abstract  boolean evaluate(DanceState ds, List<Expr> args)
          Evaluates this predicate with the arguments given in the list of Expr nodes, returning a boolean.
abstract  String getName()
          The name of this predicate, in our internal jargon.
 int hashCode()
           
static Predicate lookup(String s)
          Lookup a Predicate in the PredicateList.
 String toString()
           
 
Methods inherited from class net.cscott.sdr.calls.ExprFunc
isConstant
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Predicate

public Predicate()
Method Detail

getName

public abstract String getName()
The name of this predicate, in our internal jargon. This is meant to be human-readable, but is likely not exactly anything a caller would say.

Specified by:
getName in class ExprFunc<Boolean>

evaluate

public abstract boolean evaluate(DanceState ds,
                                 List<Expr> args)
                          throws ExprFunc.EvaluationException
Evaluates this predicate with the arguments given in the list of Expr nodes, returning a boolean.

Throws:
ExprFunc.EvaluationException

evaluate

public Boolean evaluate(Class<? super Boolean> type,
                        DanceState ds,
                        List<Expr> args)
                 throws ExprFunc.EvaluationException
Description copied from class: ExprFunc
Perform the operation of the ExprFunc on the given list of arguments args, yielding a value of the specified type. The DanceState ds is used as context for the evaluation.

Specified by:
evaluate in class ExprFunc<Boolean>
Throws:
ExprFunc.EvaluationException - on type mismatch or other unexpected conditions.

toString

public final String toString()
Overrides:
toString in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

lookup

public static Predicate lookup(String s)
Lookup a Predicate in the PredicateList.


sdr 0.7

Copyright © 2006-2009 C. Scott Ananian