org.drools.rule
Class PredicateConstraint

java.lang.Object
  extended by org.drools.rule.MutableTypeConstraint
      extended by org.drools.rule.PredicateConstraint
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, AlphaNodeFieldConstraint, BetaNodeFieldConstraint, Constraint, Restriction, RuleComponent, Wireable

public class PredicateConstraint
extends MutableTypeConstraint
implements Restriction, Wireable, Externalizable

A predicate can be written as a top level constraint or be nested inside inside a field constraint (and as so, must implement the Restriction interface).

See Also:
Serialized Form

Nested Class Summary
static class PredicateConstraint.PredicateContextEntry
           
 
Nested classes/interfaces inherited from interface org.drools.spi.Constraint
Constraint.ConstraintType
 
Constructor Summary
PredicateConstraint()
           
PredicateConstraint(Declaration[] previousDeclarations, Declaration[] localDeclarations)
           
PredicateConstraint(PredicateExpression evaluator)
           
PredicateConstraint(PredicateExpression expression, Declaration[] previousDeclarations, Declaration[] localDeclarations, String[] requiredGlobals, String[] requiredOperators)
           
 
Method Summary
 Object clone()
          Clones the constraint
 ContextEntry createContextEntry()
           
 boolean equals(Object object)
           
 Evaluator getEvaluator()
           
 Declaration[] getLocalDeclarations()
           
 PredicateExpression getPredicateExpression()
           
 Declaration[] getPreviousDeclarations()
           
 Declaration[] getRequiredDeclarations()
          Returns all the declarations required by the given constraint implementation.
 int hashCode()
           
 boolean isAllowed(InternalFactHandle handle, InternalWorkingMemory workingMemory, ContextEntry ctx)
           
 boolean isAllowed(InternalReadAccessor extractor, InternalFactHandle handle, InternalWorkingMemory workingMemory, ContextEntry context)
           
 boolean isAllowedCachedLeft(ContextEntry context, InternalFactHandle handle)
           
 boolean isAllowedCachedRight(LeftTuple tuple, ContextEntry context)
           
 boolean isTemporal()
          Returns true if this is a temporal restriction
 void readExternal(ObjectInput in)
           
 void replaceDeclaration(Declaration oldDecl, Declaration newDecl)
          A restriction may be required to replace an old declaration object by a new updated one
 void setPredicateExpression(PredicateExpression expression)
           
 String toString()
           
 void wire(Object object)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.rule.MutableTypeConstraint
getType, setType
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PredicateConstraint

public PredicateConstraint()

PredicateConstraint

public PredicateConstraint(PredicateExpression evaluator)

PredicateConstraint

public PredicateConstraint(Declaration[] previousDeclarations,
                           Declaration[] localDeclarations)

PredicateConstraint

public PredicateConstraint(PredicateExpression expression,
                           Declaration[] previousDeclarations,
                           Declaration[] localDeclarations,
                           String[] requiredGlobals,
                           String[] requiredOperators)
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class MutableTypeConstraint
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class MutableTypeConstraint
Throws:
IOException

getRequiredDeclarations

public Declaration[] getRequiredDeclarations()
Description copied from interface: Constraint
Returns all the declarations required by the given constraint implementation.

Specified by:
getRequiredDeclarations in interface Constraint
Specified by:
getRequiredDeclarations in interface Restriction
Returns:

getPreviousDeclarations

public Declaration[] getPreviousDeclarations()

getLocalDeclarations

public Declaration[] getLocalDeclarations()

replaceDeclaration

public void replaceDeclaration(Declaration oldDecl,
                               Declaration newDecl)
Description copied from interface: Restriction
A restriction may be required to replace an old declaration object by a new updated one

Specified by:
replaceDeclaration in interface Constraint
Specified by:
replaceDeclaration in interface Restriction

wire

public void wire(Object object)
Specified by:
wire in interface Wireable

setPredicateExpression

public void setPredicateExpression(PredicateExpression expression)

getPredicateExpression

public PredicateExpression getPredicateExpression()

isTemporal

public boolean isTemporal()
Description copied from interface: Restriction
Returns true if this is a temporal restriction

Specified by:
isTemporal in interface Constraint
Specified by:
isTemporal in interface Restriction
Returns:

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

createContextEntry

public ContextEntry createContextEntry()
Specified by:
createContextEntry in interface AlphaNodeFieldConstraint
Specified by:
createContextEntry in interface BetaNodeFieldConstraint
Specified by:
createContextEntry in interface Restriction

isAllowed

public boolean isAllowed(InternalFactHandle handle,
                         InternalWorkingMemory workingMemory,
                         ContextEntry ctx)
Specified by:
isAllowed in interface AlphaNodeFieldConstraint

isAllowed

public boolean isAllowed(InternalReadAccessor extractor,
                         InternalFactHandle handle,
                         InternalWorkingMemory workingMemory,
                         ContextEntry context)
Specified by:
isAllowed in interface Restriction

isAllowedCachedLeft

public boolean isAllowedCachedLeft(ContextEntry context,
                                   InternalFactHandle handle)
Specified by:
isAllowedCachedLeft in interface BetaNodeFieldConstraint
Specified by:
isAllowedCachedLeft in interface Restriction

isAllowedCachedRight

public boolean isAllowedCachedRight(LeftTuple tuple,
                                    ContextEntry context)
Specified by:
isAllowedCachedRight in interface BetaNodeFieldConstraint
Specified by:
isAllowedCachedRight in interface Restriction

clone

public Object clone()
Description copied from interface: Constraint
Clones the constraint

Specified by:
clone in interface Constraint
Specified by:
clone in interface Restriction
Specified by:
clone in class MutableTypeConstraint
Returns:

getEvaluator

public Evaluator getEvaluator()
Specified by:
getEvaluator in interface Restriction


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.