Package jade.core
Class Filter
- java.lang.Object
-
- jade.core.Filter
-
- Direct Known Subclasses:
IncomingEncodingFilter,OutgoingEncodingFilter
public abstract class Filter extends Object
Base class for command filters, that allow to set up an open-ended chain of platform services to process commands coming from the upper JADE layers. Filters process commands when theiraccept()method andpostProcessmethods are invoked; Filters in the filter chain are nested. Theaccept()method is called before the command is processed by successive filters in the chain. It should be used to take proper actions before the command consumption. On the other hand thepostProcess()method is called after the command has been processed by successive filters in the chain. It should be used to take proper actions after the command consumption.- Author:
- Giovanni Rimassa - FRAMeTech s.r.l., Giovanni Caire - TILAB
- See Also:
CommandProcessor
-
-
Field Summary
Fields Modifier and Type Field Description static intFIRSTThe constant indicating the first position in the filter chainstatic booleanINCOMINGA constant indicating a filter for incoming commandsstatic intLASTThe constant indicating the last position in the filter chainstatic booleanOUTGOINGA constant indicating a filter for outgoing commands
-
Constructor Summary
Constructors Constructor Description Filter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(VerticalCommand cmd)Process a command before it is processed by successive filters in the filter-chain.intgetPreferredPosition()Retrieve the preferred position for this filter in the filter chainbooleanisBlocking()Inquires the blocking state of this filter.booleanisSkipping()Inquires the skipping state of this filter.protected voidpostProcess(VerticalCommand cmd)Post-process a command object after it has been processed by the successive filters in the filter chain.voidsetBlocking(boolean newState)Sets the blocking state of this filter.voidsetPreferredPosition(int pos)Sets the preferred position for this filter in the filter chainvoidsetSkipping(boolean newState)Sets the skipping state of this filter.
-
-
-
Field Detail
-
FIRST
public static final int FIRST
The constant indicating the first position in the filter chain- See Also:
- Constant Field Values
-
LAST
public static final int LAST
The constant indicating the last position in the filter chain- See Also:
- Constant Field Values
-
INCOMING
public static final boolean INCOMING
A constant indicating a filter for incoming commands- See Also:
- Constant Field Values
-
OUTGOING
public static final boolean OUTGOING
A constant indicating a filter for outgoing commands- See Also:
- Constant Field Values
-
-
Method Detail
-
accept
protected boolean accept(VerticalCommand cmd)
Process a command before it is processed by successive filters in the filter-chain.- Parameters:
cmd- AVerticalCommanddescribing what operation has been requested from previous layers (that can be the actual prime source of the command or previous filters in the chain).- Returns:
- A boolean value, telling whether the filtered command has
been accepted or not. A filter can veto a command by
returning
falsefrom this method. A vetoed command is not propagated in the filter chain.
-
postProcess
protected void postProcess(VerticalCommand cmd)
Post-process a command object after it has been processed by the successive filters in the filter chain.- Parameters:
cmd- AVerticalCommanddescribing what operation has been requested from previous layers (that can be the actual prime source of the command or previous filters in the chain).
-
getPreferredPosition
public final int getPreferredPosition()
Retrieve the preferred position for this filter in the filter chain
-
setPreferredPosition
public final void setPreferredPosition(int pos)
Sets the preferred position for this filter in the filter chain
-
setBlocking
public void setBlocking(boolean newState)
Sets the blocking state of this filter. A blocked filter does not process commands, and also prevents subsequent filters to process them.- Parameters:
newState- The boolean value to set the blocking state to.
-
isBlocking
public boolean isBlocking()
Inquires the blocking state of this filter. A blocked fliter does not process commands, and also prevents subsequent filters to process them.- Returns:
- The current blocking state of this filter.
-
setSkipping
public void setSkipping(boolean newState)
Sets the skipping state of this filter. A skipped filter does not process commands, but passes them directly to subsequent filters.- Parameters:
blocked- The boolean value to set the skipping state to.
-
isSkipping
public boolean isSkipping()
Inquires the skipping state of this filter. A skipped filter does not process commands, but passes them directly to subsequent filters.- Returns:
- The current skipping state of this filter.
-
-