com.veromodo.tempo.filters.rules
Class OrRule

java.lang.Object
  extended by com.veromodo.tempo.filters.rules.OrRule
All Implemented Interfaces:
SemanticRule
Direct Known Subclasses:
IsConstantRule

public class OrRule
extends java.lang.Object
implements SemanticRule

Defines an OR of semantic rules

Semantics rule(n,X,P(n)) : Node -> Boolean defined as class(n) == X => P(n)

See Also:
BasicRule

Constructor Summary
OrRule(java.lang.Class c)
           
OrRule(ErrorLog log, MessageSource source, java.lang.Class c, java.lang.String msg)
           
 
Method Summary
 void add(SemanticRule pred)
          adds a predicate pred to the current disjunction.
 void addAll(java.util.Collection<SemanticRule> preds)
          adds a Collection of predicates to the current disjunction.
 boolean eval(ASTNode n)
          evaluates the ASTNode n.
 java.lang.Class getNodeClass()
          provides the class of the root node which the semantic Rule is defined for.
 boolean IgnoreSubtree()
          boolean value if the subtree should be ignored.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrRule

public OrRule(java.lang.Class c)
Parameters:
c - the class which the conjunction's predicates are defined on.

OrRule

public OrRule(ErrorLog log,
              MessageSource source,
              java.lang.Class c,
              java.lang.String msg)
Parameters:
log - a log to report errors to.
source - the source of the error message.
c - the class which the conjunction's predicates are defined on.
msg - a message produced if all predicates are satisified.
Method Detail

add

public void add(SemanticRule pred)
adds a predicate pred to the current disjunction.

Parameters:
pred - a predicate to be added to the disjunction.

addAll

public void addAll(java.util.Collection<SemanticRule> preds)
adds a Collection of predicates to the current disjunction.

Parameters:
preds - a Collection of predicates to be added to the disjunction

getNodeClass

public java.lang.Class getNodeClass()
Description copied from interface: SemanticRule
provides the class of the root node which the semantic Rule is defined for. This is used to filter when a check is executed, so that it is not performed on every node.

Specified by:
getNodeClass in interface SemanticRule
Returns:
the class which this is defined on.

IgnoreSubtree

public boolean IgnoreSubtree()
Description copied from interface: SemanticRule
boolean value if the subtree should be ignored. This is used to to deside if the subtree should have the current set of rules applied to it.

Specified by:
IgnoreSubtree in interface SemanticRule
Returns:
true if the subtree should be ignored

eval

public boolean eval(ASTNode n)
evaluates the ASTNode n. Returns true if the ASTNode matches the critera of one predicate, false otherwise. Reports errors if nessisary.

Specified by:
eval in interface SemanticRule
Parameters:
n - an ASTNode to be checked.
Returns:
true if the ASTNode matches at least one predicate.