CSP for Java
(JCSP) 1.1-rc4

org.jcsp.util.filter
Interface ReadFiltered

All Known Subinterfaces:
FilteredChannelInput, FilteredSharedChannelInput, MigratableChannelInput
All Known Implementing Classes:
FilteredAltingChannelInput, FilteredSharedChannelInputWrapper, MigratableAltingChannelInput

public interface ReadFiltered

Interface for a channel end supporting read filtering operations. A channel end that implements this interface can have instances of the Filter interface installed to apply transformations on data as it is read from the channel.

Multiple filters can be installed and referenced by a zero-based index to specify a specific ordering.

If multiple filters are installed, they are applied in order of increasing index. For example:

   FilteredChannelInput in = ...;

   Filter f1 = ...;
   Filter f2 = ...;

   in.addReadFilter (f1, 0);
   in.addReadFilter (f2, 1);
 

The in.read() method will return f2.filter (f1.filter (obj)) where obj is the data value that would have been delivered in the absence of filters.

Author:
Quickstone Technologies Limited
See Also:
Filter, FilteredChannelInput

Method Summary
 void addReadFilter(Filter filter)
          Installs a read filter defining a transformation to be applied by the read method of the channel end.
 void addReadFilter(Filter filter, int index)
          Installs a read filter defining a transformation to be applied by the read method of the channel end at a specific index.
 Filter getReadFilter(int index)
          Returns the read filter installed at the given index.
 int getReadFilterCount()
          Returns the number of read filters currently installed.
 void removeReadFilter(Filter filter)
          Removes the first read filter (lowest index) matching the filter given as a parameter.
 void removeReadFilter(int index)
          Removes the read filter installed at the given index.
 

Method Detail

addReadFilter

void addReadFilter(Filter filter)
Installs a read filter defining a transformation to be applied by the read method of the channel end. The filter will be appended to the end of the current list, making it the last to be applied.

Parameters:
filter - the filter to be installed; may not be null.

addReadFilter

void addReadFilter(Filter filter,
                   int index)
Installs a read filter defining a transformation to be applied by the read 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.

Parameters:
filter - the filter to be installed; may not be null.
index - the zero based index; may not be negative.

removeReadFilter

void removeReadFilter(Filter filter)
Removes the first read 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.

Parameters:
filter - the filter to be removed; may not be null.

removeReadFilter

void removeReadFilter(int index)
Removes the read filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.

Parameters:
index - zero-based index of the filter to be removed.

getReadFilter

Filter getReadFilter(int index)
Returns the read filter installed at the given index.

Parameters:
index - zero-based index of the filter to return.
Returns:
the filter at that position.

getReadFilterCount

int getReadFilterCount()
Returns the number of read filters currently installed.


CSP for Java
(JCSP) 1.1-rc4

Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.