Drools :: Core 6.1.0.Beta1

org.drools.core.rule
Class SlidingLengthWindow

java.lang.Object
  extended by 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
static class SlidingLengthWindow.SlidingLengthWindowContext
          A Context object for length windows
 
Nested classes/interfaces inherited from interface org.drools.core.rule.Behavior
Behavior.BehaviorType
 
Field Summary
 
Fields inherited from interface org.drools.core.rule.Behavior
EMPTY_BEHAVIOR_LIST
 
Constructor Summary
SlidingLengthWindow()
           
SlidingLengthWindow(int size)
           
 
Method Summary
 boolean assertFact(WindowNode.WindowMemory memory, Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
          Makes the behavior aware of the new fact entering behavior's scope
 Object createContext()
          Creates the context object associated with this behavior.
 void expireFacts(WindowNode.WindowMemory memory, Object context, PropagationContext pctx, InternalWorkingMemory workingMemory)
          A callback method that allows behaviors to expire facts
 long getExpirationOffset()
          Length windows don't change expiration offset, so always return -1
 long getSize()
           
 Behavior.BehaviorType getType()
          Returns the type of the behavior
 void readExternal(ObjectInput in)
           
 void retractFact(WindowNode.WindowMemory memory, Object context, InternalFactHandle handle, PropagationContext pctx, InternalWorkingMemory workingMemory)
          Removes a right tuple from the behavior's scope
 void setSize(int size)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SlidingLengthWindow

public SlidingLengthWindow()

SlidingLengthWindow

public SlidingLengthWindow(int size)
Parameters:
size -
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException
See Also:
Externalizable.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException
See Also:
Externalizable.writeExternal(java.io.ObjectOutput)

getType

public Behavior.BehaviorType getType()
Description copied from interface: Behavior
Returns the type of the behavior

Specified by:
getType in interface Behavior
Returns:

getSize

public long getSize()
Returns:
the size

setSize

public void setSize(int size)
Parameters:
size - the size to set

createContext

public Object 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 interface Behavior
Returns:

assertFact

public boolean assertFact(WindowNode.WindowMemory memory,
                          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 interface Behavior
Parameters:
memory - The window node memory
context - The behavior context object
handle - The new fact entering behavior's scope
workingMemory - 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(WindowNode.WindowMemory memory,
                        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 interface Behavior
Parameters:
memory - The window node memory
context - The behavior context object
handle - The fact leaving the behavior's scope
workingMemory - The working memory session reference

expireFacts

public void expireFacts(WindowNode.WindowMemory memory,
                        Object context,
                        PropagationContext pctx,
                        InternalWorkingMemory workingMemory)
Description copied from interface: Behavior
A callback method that allows behaviors to expire facts

Specified by:
expireFacts in interface Behavior
Parameters:
memory - The window node memory
context - The behavior context object
workingMemory - The working memory session reference

getExpirationOffset

public long getExpirationOffset()
Length windows don't change expiration offset, so always return -1

Specified by:
getExpirationOffset in interface Behavior
Returns:
the expiration offset for this behavior or -1 if they don't have a time based expiration offset.

toString

public String toString()
Overrides:
toString in class Object

Drools :: Core 6.1.0.Beta1

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