com.veromodo.tempo.filters.rules
Class AndRule

java.lang.Object
  extended by com.veromodo.tempo.filters.rules.AndRule
All Implemented Interfaces:
SemanticRule

public class AndRule
extends java.lang.Object
implements SemanticRule

Defines an AND of semantic rules

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

See Also:
BasicRule

Constructor Summary
AndRule(ErrorLog log, java.lang.Class c)
           
AndRule(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 conjunction.
 void addAll(java.util.Collection<SemanticRule> preds)
          adds a Collection of predicates to the current conjunction.
 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

AndRule

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

AndRule

public AndRule(ErrorLog log,
               MessageSource source,
               java.lang.Class c,
               java.lang.String msg)
Parameters:
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 conjunction.

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

addAll

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

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

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 all predicates, 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 all predicates.