Package jade.core

Class 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 their accept() method and postProcess methods are invoked; Filters in the filter chain are nested. The accept() 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 the postProcess() 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 int FIRST
      The constant indicating the first position in the filter chain
      static boolean INCOMING
      A constant indicating a filter for incoming commands
      static int LAST
      The constant indicating the last position in the filter chain
      static boolean OUTGOING
      A constant indicating a filter for outgoing commands
    • Constructor Summary

      Constructors 
      Constructor Description
      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
    • Constructor Detail

      • Filter

        public Filter()
    • Method Detail

      • accept

        protected boolean accept​(VerticalCommand cmd)
        Process a command before it is processed by successive filters in the filter-chain.
        Parameters:
        cmd - A VerticalCommand describing 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 false from 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 - A VerticalCommand describing 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.