CSP for Java
(JCSP) 1.1-rc4

org.jcsp.util.filter
Class FilteredSharedChannelInputWrapper

java.lang.Object
  extended by org.jcsp.lang.ChannelInputWrapper
      extended by org.jcsp.util.filter.FilteredSharedChannelInputWrapper
All Implemented Interfaces:
ChannelInput, Poisonable, SharedChannelInput, FilteredChannelInput, FilteredSharedChannelInput, ReadFiltered

public class FilteredSharedChannelInputWrapper
extends ChannelInputWrapper
implements FilteredSharedChannelInput

This is wrapper for a SharedChannelInput that adds read filtering. Instances of this class can be safely used by multiple concurrent processes.

Author:
Quickstone Technologies Limited

Constructor Summary
FilteredSharedChannelInputWrapper(SharedChannelInput in)
          Constructs a new wrapper for the given channel input end.
 
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.
 Object read()
          Reads a value from the channel.
 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.
 
Methods inherited from class org.jcsp.lang.ChannelInputWrapper
endRead, poison, startRead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jcsp.lang.ChannelInput
endRead, startRead
 
Methods inherited from interface org.jcsp.lang.Poisonable
poison
 
Methods inherited from interface org.jcsp.lang.ChannelInput
endRead, startRead
 
Methods inherited from interface org.jcsp.lang.Poisonable
poison
 

Constructor Detail

FilteredSharedChannelInputWrapper

public FilteredSharedChannelInputWrapper(SharedChannelInput in)
Constructs a new wrapper for the given channel input end.

Parameters:
in - the existing channel end.
Method Detail

read

public Object read()
Description copied from class: ChannelInputWrapper
Reads a value from the channel.

Specified by:
read in interface ChannelInput
Returns:
the value read.
See Also:
ChannelInput

addReadFilter

public void addReadFilter(Filter filter)
Description copied from interface: ReadFiltered
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.

Specified by:
addReadFilter in interface ReadFiltered
Parameters:
filter - the filter to be installed; may not be null.

addReadFilter

public void addReadFilter(Filter filter,
                          int index)
Description copied from interface: ReadFiltered
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.

Specified by:
addReadFilter in interface ReadFiltered
Parameters:
filter - the filter to be installed; may not be null.
index - the zero based index; may not be negative.

removeReadFilter

public void removeReadFilter(Filter filter)
Description copied from interface: ReadFiltered
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.

Specified by:
removeReadFilter in interface ReadFiltered
Parameters:
filter - the filter to be removed; may not be null.

removeReadFilter

public void removeReadFilter(int index)
Description copied from interface: ReadFiltered
Removes the read filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.

Specified by:
removeReadFilter in interface ReadFiltered
Parameters:
index - zero-based index of the filter to be removed.

getReadFilter

public Filter getReadFilter(int index)
Description copied from interface: ReadFiltered
Returns the read filter installed at the given index.

Specified by:
getReadFilter in interface ReadFiltered
Parameters:
index - zero-based index of the filter to return.
Returns:
the filter at that position.

getReadFilterCount

public int getReadFilterCount()
Description copied from interface: ReadFiltered
Returns the number of read filters currently installed.

Specified by:
getReadFilterCount in interface ReadFiltered

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.