Package org.drools.core.rule
Class SlidingLengthWindow
- java.lang.Object
-
- org.drools.core.rule.SlidingLengthWindow
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Behavior
,RuleComponent
public class SlidingLengthWindow extends Object implements Externalizable, Behavior
A length window behavior implementation- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SlidingLengthWindow.SlidingLengthWindowContext
A Context object for length windows-
Nested classes/interfaces inherited from interface org.drools.core.rule.Behavior
Behavior.BehaviorType, Behavior.Context
-
-
Field Summary
Fields Modifier and Type Field Description protected int
size
-
Constructor Summary
Constructors Constructor Description SlidingLengthWindow()
SlidingLengthWindow(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
assertFact(Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
Makes the behavior aware of the new fact entering behavior's scopeBehavior.Context
createContext()
Creates the context object associated with this behavior.void
expireFacts(Object context, PropagationContext pctx, InternalWorkingMemory workingMemory)
A callback method that allows behaviors to expire factslong
getExpirationOffset()
Length windows don't change expiration offset, so always return -1long
getSize()
Behavior.BehaviorType
getType()
Returns the type of the behaviorvoid
readExternal(ObjectInput in)
void
retractFact(Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
Removes a right tuple from the behavior's scopevoid
setSize(int size)
String
toString()
void
writeExternal(ObjectOutput out)
-
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
getType
public Behavior.BehaviorType getType()
Description copied from interface:Behavior
Returns the type of the behavior
-
getSize
public long getSize()
- Returns:
- the size
-
setSize
public void setSize(int size)
- Parameters:
size
- the size to set
-
createContext
public Behavior.Context createContext()
Description copied from interface:Behavior
Creates the context object associated with this behavior. The object is given as a parameter in all behavior call backs.- Specified by:
createContext
in interfaceBehavior
-
assertFact
public boolean assertFact(Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
Description copied from interface:Behavior
Makes the behavior aware of the new fact entering behavior's scope- Specified by:
assertFact
in interfaceBehavior
- Parameters:
context
- The behavior context objecthandle
- The new fact entering behavior's scopeworkingMemory
- The working memory session reference- Returns:
- true if the propagation should continue, false otherwise. I.e., the behaviour has veto power over the fact propagation, and prevents the propagation to continue if returns false on this method.
-
retractFact
public void retractFact(Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
Description copied from interface:Behavior
Removes a right tuple from the behavior's scope- Specified by:
retractFact
in interfaceBehavior
- Parameters:
context
- The behavior context objecthandle
- The fact leaving the behavior's scopeworkingMemory
- The working memory session reference
-
expireFacts
public void expireFacts(Object context, PropagationContext pctx, InternalWorkingMemory workingMemory)
Description copied from interface:Behavior
A callback method that allows behaviors to expire facts- Specified by:
expireFacts
in interfaceBehavior
-
getExpirationOffset
public long getExpirationOffset()
Length windows don't change expiration offset, so always return -1- Specified by:
getExpirationOffset
in interfaceBehavior
- Returns:
- the expiration offset for this behavior or -1 if they don't have a time based expiration offset.
-
-