Package org.drools.core.rule
Class Pattern
- java.lang.Object
-
- org.drools.core.rule.Pattern
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Cloneable,AcceptsClassObjectType,RuleComponent,RuleConditionElement
- Direct Known Subclasses:
XpathBackReference.RelativePattern
public class Pattern extends java.lang.Object implements RuleConditionElement, AcceptsClassObjectType, java.io.Externalizable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Pattern()Pattern(int patternId, int tupleIndex, int objectIndex, ObjectType objectType, java.lang.String identifier)Pattern(int patternId, int tupleIndex, int objectIndex, ObjectType objectType, java.lang.String identifier, boolean isInternalFact)Pattern(int patternId, ObjectType objectType)Pattern(int patternId, ObjectType objectType, java.lang.String identifier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBehavior(Behavior behavior)voidaddBoundProperty(java.lang.String boundProperty)voidaddConstraint(int index, Constraint constraint)voidaddConstraint(Constraint constraint)voidaddConstraints(java.util.Collection<Constraint> constraints)DeclarationaddDeclaration(java.lang.String identifier)voidaddDeclaration(Declaration decl)voidaddWatchedProperties(java.util.Collection<java.lang.String> watchedProperties)voidaddWatchedProperty(java.lang.String watchedProperty)Patternclone()Returns a clone from itselfbooleanequals(java.lang.Object object)java.util.List<java.lang.String>getAccessibleProperties(RuleBase ruleBase)java.util.Map<java.lang.String,AnnotationDefinition>getAnnotations()XpathBackReferencegetBackRefDeclarations()java.util.List<Behavior>getBehaviors()java.util.List<Constraint>getConstraints()DeclarationgetDeclaration()java.util.Map<java.lang.String,Declaration>getDeclarations()java.util.Map<java.lang.String,Declaration>getInnerDeclarations()Returns a Map of declarations that are visible inside this conditional elementjava.util.Collection<java.lang.String>getListenedProperties()BitMaskgetNegativeWatchMask(java.util.List<java.lang.String> accessibleProperties)java.util.List<RuleConditionElement>getNestedElements()Returs a list of RuleConditionElement's that are nested inside the current elementintgetObjectIndex()ObjectTypegetObjectType()java.util.Map<java.lang.String,Declaration>getOuterDeclarations()Returns a Map of declarations that are visible outside this conditional element.intgetPatternId()The index of the Pattern, in the list of patterns.BitMaskgetPositiveWatchMask(java.util.List<java.lang.String> accessibleProperties)Declaration[]getRequiredDeclarations()PatternSourcegetSource()intgetTupleIndex()The index of pattern in the tuple chain.java.util.List<java.lang.Class<?>>getXpathBackReferenceClasses()XpathConstraintgetXpathConstraint()DeclarationgetXPathDeclaration()inthashCode()booleanhasNegativeConstraint()booleanhasXPath()booleanisBound()booleanisCompatibleWithAccumulateReturnType(java.lang.Class<?> returnType)static booleanisCompatibleWithAccumulateReturnType(java.lang.Class<?> patternType, java.lang.Class<?> returnType)booleanisCompatibleWithFromReturnType(java.lang.Class<?> returnType)static booleanisCompatibleWithFromReturnType(java.lang.Class<?> patternType, java.lang.Class<?> returnType)booleanisPassive()booleanisPatternScopeDelimiter()Returns true in case this RuleConditionElement delimits a pattern visibility scope.voidreadExternal(java.io.ObjectInput in)voidremoveConstraint(Constraint constraint)voidresetDeclarations()DeclarationresolveDeclaration(java.lang.String identifier)Resolves the given identifier in the current scope and returns the Declaration object for the declaration.voidsetBackRefDeclarations(XpathBackReference backRefDeclarations)voidsetBehaviors(java.util.List<Behavior> behaviors)voidsetClassObjectType(ClassObjectType objectType)voidsetHasNegativeConstraint(boolean negative)voidsetNegativeWatchMask(BitMask negativeWatchMask)voidsetObjectIndex(int objectIndex)voidsetObjectType(ObjectType objectType)voidsetPassive(boolean passive)voidsetPositiveWatchMask(BitMask positiveWatchMask)voidsetSource(PatternSource source)voidsetTupleIndex(int tupleIndex)java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Constructor Detail
-
Pattern
public Pattern()
-
Pattern
public Pattern(int patternId, ObjectType objectType)
-
Pattern
public Pattern(int patternId, ObjectType objectType, java.lang.String identifier)
-
Pattern
public Pattern(int patternId, int tupleIndex, int objectIndex, ObjectType objectType, java.lang.String identifier)
-
Pattern
public Pattern(int patternId, int tupleIndex, int objectIndex, ObjectType objectType, java.lang.String identifier, boolean isInternalFact)
-
-
Method Detail
-
hasNegativeConstraint
public boolean hasNegativeConstraint()
-
setHasNegativeConstraint
public void setHasNegativeConstraint(boolean negative)
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
setClassObjectType
public void setClassObjectType(ClassObjectType objectType)
- Specified by:
setClassObjectTypein interfaceAcceptsClassObjectType
-
getRequiredDeclarations
public Declaration[] getRequiredDeclarations()
-
clone
public Pattern clone()
Description copied from interface:RuleConditionElementReturns a clone from itself- Specified by:
clonein interfaceRuleConditionElement- Overrides:
clonein classjava.lang.Object- Returns:
-
getObjectType
public ObjectType getObjectType()
-
setObjectType
public void setObjectType(ObjectType objectType)
-
getSource
public PatternSource getSource()
-
setSource
public void setSource(PatternSource source)
-
isPassive
public boolean isPassive()
-
setPassive
public void setPassive(boolean passive)
-
getConstraints
public java.util.List<Constraint> getConstraints()
-
addConstraint
public void addConstraint(int index, Constraint constraint)
-
addConstraints
public void addConstraints(java.util.Collection<Constraint> constraints)
-
addConstraint
public void addConstraint(Constraint constraint)
-
removeConstraint
public void removeConstraint(Constraint constraint)
-
hasXPath
public boolean hasXPath()
-
getXpathConstraint
public XpathConstraint getXpathConstraint()
-
getXPathDeclaration
public Declaration getXPathDeclaration()
-
addDeclaration
public Declaration addDeclaration(java.lang.String identifier)
-
addDeclaration
public void addDeclaration(Declaration decl)
-
resetDeclarations
public void resetDeclarations()
-
isBound
public boolean isBound()
-
getDeclaration
public Declaration getDeclaration()
-
getPatternId
public int getPatternId()
The index of the Pattern, in the list of patterns.- Returns:
- the patternIndex
-
getObjectIndex
public int getObjectIndex()
-
setObjectIndex
public void setObjectIndex(int objectIndex)
-
getTupleIndex
public int getTupleIndex()
The index of pattern in the tuple chain.- Returns:
- the tupleIndex
-
setTupleIndex
public void setTupleIndex(int tupleIndex)
-
getDeclarations
public java.util.Map<java.lang.String,Declaration> getDeclarations()
-
getInnerDeclarations
public java.util.Map<java.lang.String,Declaration> getInnerDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible inside this conditional element- Specified by:
getInnerDeclarationsin interfaceRuleConditionElement- Returns:
-
getOuterDeclarations
public java.util.Map<java.lang.String,Declaration> getOuterDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible outside this conditional element.- Specified by:
getOuterDeclarationsin interfaceRuleConditionElement- Returns:
-
resolveDeclaration
public Declaration resolveDeclaration(java.lang.String identifier)
Description copied from interface:RuleConditionElementResolves the given identifier in the current scope and returns the Declaration object for the declaration. Returns null if identifier can not be resolved.- Specified by:
resolveDeclarationin interfaceRuleConditionElement- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
getNestedElements
public java.util.List<RuleConditionElement> getNestedElements()
Description copied from interface:RuleConditionElementReturs a list of RuleConditionElement's that are nested inside the current element- Specified by:
getNestedElementsin interfaceRuleConditionElement- Returns:
-
isPatternScopeDelimiter
public boolean isPatternScopeDelimiter()
Description copied from interface:RuleConditionElementReturns true in case this RuleConditionElement delimits a pattern visibility scope. For instance, AND CE is not a scope delimiter, while NOT CE is a scope delimiter- Specified by:
isPatternScopeDelimiterin interfaceRuleConditionElement- Returns:
-
getBehaviors
public java.util.List<Behavior> getBehaviors()
- Returns:
- the behaviors
-
setBehaviors
public void setBehaviors(java.util.List<Behavior> behaviors)
- Parameters:
behaviors- the behaviors to set
-
addBehavior
public void addBehavior(Behavior behavior)
-
getListenedProperties
public java.util.Collection<java.lang.String> getListenedProperties()
-
addBoundProperty
public void addBoundProperty(java.lang.String boundProperty)
-
addWatchedProperty
public void addWatchedProperty(java.lang.String watchedProperty)
-
addWatchedProperties
public void addWatchedProperties(java.util.Collection<java.lang.String> watchedProperties)
-
getAccessibleProperties
public java.util.List<java.lang.String> getAccessibleProperties(RuleBase ruleBase)
-
getPositiveWatchMask
public BitMask getPositiveWatchMask(java.util.List<java.lang.String> accessibleProperties)
-
setPositiveWatchMask
public void setPositiveWatchMask(BitMask positiveWatchMask)
-
getNegativeWatchMask
public BitMask getNegativeWatchMask(java.util.List<java.lang.String> accessibleProperties)
-
setNegativeWatchMask
public void setNegativeWatchMask(BitMask negativeWatchMask)
-
getAnnotations
public java.util.Map<java.lang.String,AnnotationDefinition> getAnnotations()
-
getBackRefDeclarations
public XpathBackReference getBackRefDeclarations()
-
setBackRefDeclarations
public void setBackRefDeclarations(XpathBackReference backRefDeclarations)
-
getXpathBackReferenceClasses
public java.util.List<java.lang.Class<?>> getXpathBackReferenceClasses()
-
isCompatibleWithAccumulateReturnType
public boolean isCompatibleWithAccumulateReturnType(java.lang.Class<?> returnType)
-
isCompatibleWithFromReturnType
public boolean isCompatibleWithFromReturnType(java.lang.Class<?> returnType)
-
isCompatibleWithAccumulateReturnType
public static boolean isCompatibleWithAccumulateReturnType(java.lang.Class<?> patternType, java.lang.Class<?> returnType)
-
isCompatibleWithFromReturnType
public static boolean isCompatibleWithFromReturnType(java.lang.Class<?> patternType, java.lang.Class<?> returnType)
-
-