Package net.sf.eBus.feed.pattern
Class EPatternFeed.AbstractMatchFrame
- java.lang.Object
-
- net.sf.eBus.feed.pattern.EPatternFeed.AbstractMatchFrame
-
- Enclosing class:
- EPatternFeed
protected abstract static class EPatternFeed.AbstractMatchFrame extends Object
A match frame tracks an in-progress match. When a frame contains a complete pattern match the frame is used to generate theMatchEventposted to the subscriber. Match frames are kept until either an event violates the pattern or the match completes.Base class for
EOrderPatternFeed.MatchFrameandEUnorderedPatternFeed.MatchFrame.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ENotificationMessage>mAllEventsContains all events matching the pattern so far.protected booleanmIsDefunctSet totruewhen a match frame is 1) used for an exclusive pattern, 2) the pattern is completely matched, and 3) this frame contains common events with the completely matched frame.protected booleanmIsExclusivetrueif this match frame is for an exclusive pattern.protected StringmPatternNameMatch frame created by this pattern.protected Map<Object,Object>mUserCacheCache for storing interim, user-defined data calculated while performing aMatchCondition.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMatchFrame(String patternName, boolean isExclusive)Creates a new match frame for the given pattern and exclusivity flag.protectedAbstractMatchFrame(EPatternFeed.AbstractMatchFrame frame)Copies the given frame data into this frame.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<ENotificationMessage>allEvents()Returns the "all events" collection as an unmodifiable list.intframeId()Returns the unique match frame identifier.protected abstract Map<String,List<ENotificationMessage>>groupMap()Returns a read-only copy of the group map.booleanisDefunct()Returnstrueif this match frame is defunct due to a prior exclusive matching and, therefore, may no longer be used.booleanisExclusive()Returnstrueif this is an exclusive feed;falseotherwise.StringpatternName()Returns the pattern name.voidsetDefunct()Marks this match frame as defunct.StringtoString()Map<Object,Object>userCache()Returns the user-defined match data cache.
-
-
-
Field Detail
-
mPatternName
protected final String mPatternName
Match frame created by this pattern. Used for logging purposes.
-
mAllEvents
protected final List<ENotificationMessage> mAllEvents
Contains all events matching the pattern so far. Since these events are repeatedly referenced by the matching algorithm, this list is kept for quick reference.
-
mUserCache
protected final Map<Object,Object> mUserCache
Cache for storing interim, user-defined data calculated while performing aMatchCondition.
-
mIsExclusive
protected final boolean mIsExclusive
trueif this match frame is for an exclusive pattern. That means events may not be used for multiple matches within the same pattern.
-
mIsDefunct
protected boolean mIsDefunct
Set totruewhen a match frame is 1) used for an exclusive pattern, 2) the pattern is completely matched, and 3) this frame contains common events with the completely matched frame. Otherwise, will befalse. Marking a match frame as defunct allows for "lazy removal" from the frames queue.
-
-
Constructor Detail
-
AbstractMatchFrame
protected AbstractMatchFrame(String patternName, boolean isExclusive)
Creates a new match frame for the given pattern and exclusivity flag.- Parameters:
patternName- pattern name.isExclusive-trueif the pattern is exclusive.
-
AbstractMatchFrame
protected AbstractMatchFrame(EPatternFeed.AbstractMatchFrame frame)
Copies the given frame data into this frame.- Parameters:
frame- copy this frame.
-
-
Method Detail
-
groupMap
protected abstract Map<String,List<ENotificationMessage>> groupMap()
Returns a read-only copy of the group map. This is necessary since the returned map is passed to the client-defined match condition and the client is not allowed to modify this map.- Returns:
- group map read-only copy.
-
patternName
public final String patternName()
Returns the pattern name.- Returns:
- pattern name.
-
frameId
public final int frameId()
Returns the unique match frame identifier.- Returns:
- match frame identifier.
-
isExclusive
public final boolean isExclusive()
Returnstrueif this is an exclusive feed;falseotherwise.- Returns:
trueif this is an exclusive feed;
-
allEvents
public final List<ENotificationMessage> allEvents()
Returns the "all events" collection as an unmodifiable list.- Returns:
- unmodifiable all events list.
-
userCache
public final Map<Object,Object> userCache()
Returns the user-defined match data cache.- Returns:
- user match data cache.
-
isDefunct
public final boolean isDefunct()
Returnstrueif this match frame is defunct due to a prior exclusive matching and, therefore, may no longer be used.- Returns:
trueif defunct.
-
setDefunct
public final void setDefunct()
Marks this match frame as defunct. Next time this frame is removed from the frame queue, it will be ignored.
-
-