Class FilteredChannelOutputWrapper

java.lang.Object
org.jcsp.lang.ChannelOutputWrapper
org.jcsp.util.filter.FilteredChannelOutputWrapper
All Implemented Interfaces:
ChannelOutput, Poisonable, FilteredChannelOutput, WriteFiltered
Direct Known Subclasses:
FilteredSharedChannelOutputWrapper

class FilteredChannelOutputWrapper extends ChannelOutputWrapper implements FilteredChannelOutput
Wrapper for an output channel end to include write filtering ability.
  • Field Details

    • filters

      private FilterHolder filters
      Set of write filters installed.
  • Constructor Details

    • FilteredChannelOutputWrapper

      public FilteredChannelOutputWrapper(ChannelOutput out)
      Constructs a new FilteredChannelOutputWrapper around the given output channel end.
      Parameters:
      out - the existing output channel.
  • Method Details

    • write

      public void write(Object data)
      Description copied from class: ChannelOutputWrapper
      Writes a value to the channel.
      Specified by:
      write in interface ChannelOutput
      Overrides:
      write in class ChannelOutputWrapper
      Parameters:
      data - the value to write.
      See Also:
    • addWriteFilter

      public void addWriteFilter(Filter filter)
      Description copied from interface: WriteFiltered
      Installs a write filter defining a transformation to be applied by the write method of the channel end. The filter will be appended to the end of the current list, making it the last to be applied.
      Specified by:
      addWriteFilter in interface WriteFiltered
      Parameters:
      filter - the filter to be installed; may not be null.
    • addWriteFilter

      public void addWriteFilter(Filter filter, int index)
      Description copied from interface: WriteFiltered
      Installs a write filter defining a transformation to be applied by the write method of the channel end at a specific index. If there is already a filter at that index position the existing filters are shifted to make room. If the index is greater than the number of filters already installed the filter is placed at the end.
      Specified by:
      addWriteFilter in interface WriteFiltered
      Parameters:
      filter - the filter to be installed; may not be null.
      index - the zero based index; may not be negative.
    • removeWriteFilter

      public void removeWriteFilter(Filter filter)
      Description copied from interface: WriteFiltered
      Removes the first write filter (lowest index) matching the filter given as a parameter. The filter removed, r, will satisfy the condition r.equals (filter). The remaining filters are shifted to close the gap in the index allocation.
      Specified by:
      removeWriteFilter in interface WriteFiltered
      Parameters:
      filter - the filter to be removed; may not be null.
    • removeWriteFilter

      public void removeWriteFilter(int index)
      Description copied from interface: WriteFiltered
      Removes the write filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.
      Specified by:
      removeWriteFilter in interface WriteFiltered
      Parameters:
      index - zero-based index of the filter to be removed.
    • getWriteFilter

      public Filter getWriteFilter(int index)
      Description copied from interface: WriteFiltered
      Returns the write filter installed at the given index.
      Specified by:
      getWriteFilter in interface WriteFiltered
      Parameters:
      index - zero-based index of the filter to return.
      Returns:
      the filter at that position.
    • getWriteFilterCount

      public int getWriteFilterCount()
      Description copied from interface: WriteFiltered
      Returns the number of write filters currently installed.
      Specified by:
      getWriteFilterCount in interface WriteFiltered