Class BasicRule<T>

  extended by com.veromodo.tempo.filters.rules.BasicRule<T>
Type Parameters:
T - the type of objects which the internal predicates are to work on
All Implemented Interfaces:
Direct Known Subclasses:
DoNotCallRule, DoNotDereferenceArrayRule, DoNotDereferenceFieldRule, DoNotUseIdRule, InsideAutomatonRule

public class BasicRule<T>
extends java.lang.Object
implements SemanticRule

a wrapper class for a SemanticRule on an ASTNode.

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

Given a node type in the form of a Class c and a SemanticRule, this class sets up the evaluation of the rule

It is crucial that the SemanticRule is defined for the Class c, c is the runtime mechanism used to decide whether SemanticRule applies. If SemanticRule is not defined for c a class cast exception is likely to be thrown in the eval method.

See Also:

Constructor Summary
BasicRule(java.lang.Class c, SemanticPredicate<T> pred)
Method Summary
 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


public BasicRule(java.lang.Class c,
                 SemanticPredicate<T> pred)
c - the class which pred is defined on.
pred - a predicate to evaluate an ASTNode
Method Detail


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
the class which this rule is defined on.


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
true if the subtree should be ignored


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

Specified by:
eval in interface SemanticRule
n - an ASTNode to be checked.
true if the ASTNode matches.