Class ActionSet

java.lang.Object
org.simpleframework.transport.reactor.ActionSet

class ActionSet extends Object
The ActionSet object represents a set of actions that are associated with a particular selection key. Here the set stores an Action for each of the interested operation types. In some situations a single action may be interested in several operations which must be remembered by the set.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final SelectionKey
    This is the selection key associated with the action set.
    private final Action[]
    This contains the the actions indexed by operation type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the ActionSet object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attach(Action action)
    This is used to attach an action to the set for a specific interest bitmask.
    void
    This is used to cancel the SelectionKey associated with the action set.
    This provides the channel associated with the action set.
    void
    This is used to clear all interest from the set.
    private Action[]
    copyOf(Action[] list, int count)
    This is used to create a copy of the specified list with only the first few non null values.
    get(int interest)
    This is used to acquire the actions that match the bitmask of interest operations.
    int
    This is used to acquire the operations that this is interested in.
    key()
    This provides the selection key associated with the action set.
    This provides an iterator of the actions that exist within the action set.
    This is sued to acquire all actions that match the currently ready operations of the key.
    remove(int interest)
    This is used to remove interest from the set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • key

      private final SelectionKey key
      This is the selection key associated with the action set.
    • set

      private final Action[] set
      This contains the the actions indexed by operation type.
  • Constructor Details

    • ActionSet

      public ActionSet(SelectionKey key)
      Constructor for the ActionSet object. This is used to create a set for storing actions keyed by operation type. Only one action is kept per operation type.
      Parameters:
      key - this is the associated selection key
  • Method Details

    • key

      public SelectionKey key()
      This provides the selection key associated with the action set. For each ready operation on the selection key the set contains an action that can be executed.
      Returns:
      this provides the selection key for this action set
    • channel

      public SelectableChannel channel()
      This provides the channel associated with the action set. This is the channel that is registered for selection using the interested operations for the set.
      Returns:
      this returns the selectable channel for the action set
    • list

      public Action[] list()
      This provides an iterator of the actions that exist within the action set. Regardless of whether a single action is interested is several operations this will return an iteration of unique actions. Modifications to the iterator do not affect the set.
      Returns:
      this returns an iterator of unique actions for the set
    • ready

      public Action[] ready()
      This is sued to acquire all actions that match the currently ready operations of the key. All actions returned by this will be executed and the interest will typically be removed.
      Returns:
      returns the array of ready operations for the set
    • attach

      public void attach(Action action)
      This is used to attach an action to the set for a specific interest bitmask. If the bitmask contains several operations then the action is registered for each individual operation.
      Parameters:
      action - this is the action that is to be attached
      interest - this is the interest for the action
    • remove

      public Action[] remove(int interest)
      This is used to remove interest from the set. Removal of interest from the set is performed by registering a null for the interest operation.
      Parameters:
      interest - this is the interest to be removed
    • get

      public Action[] get(int interest)
      This is used to acquire the actions that match the bitmask of interest operations. If there are no actions representing the interest required an empty array will be returned.
      Parameters:
      interest - this is the interest to acquire actions for
      Returns:
      this will return an array of actions for the interest
    • copyOf

      private Action[] copyOf(Action[] list, int count)
      This is used to create a copy of the specified list with only the first few non null values. This ensures we can keep the internal array immutable and still use arrays.
      Parameters:
      list - this is the list that is to be copied to a new array
      count - this is the number of entries to copy from the list
      Returns:
      a copy of the original list up to the specified count
    • interest

      public int interest()
      This is used to acquire the operations that this is interested in. If there are currently no registered actions then this will return zero. Interest is represented by non-null actions only.
      Returns:
      this returns the interested operations for this
    • clear

      public void clear()
      This is used to clear all interest from the set. This will basically clear out any actions that have been registered with the set. After invocation the iterator will be empty.
    • cancel

      public void cancel()
      This is used to cancel the SelectionKey associated with the action set. Canceling the key in this manner ensures it is not returned in further selection operations.