Package org.jcsp.util.filter
Class FilteredChannelInputWrapper
- java.lang.Object
-
- org.jcsp.lang.ChannelInputWrapper
-
- org.jcsp.util.filter.FilteredChannelInputWrapper
-
- All Implemented Interfaces:
ChannelInput,Poisonable,FilteredChannelInput,ReadFiltered
- Direct Known Subclasses:
FilteredSharedChannelInputWrapper
class FilteredChannelInputWrapper extends ChannelInputWrapper implements FilteredChannelInput
Wrapper for an input channel end to include read filtering functionality.
-
-
Field Summary
Fields Modifier and Type Field Description private FilterHolderfiltersSet of read filters installed.
-
Constructor Summary
Constructors Constructor Description FilteredChannelInputWrapper(ChannelInput in)Constructs a newFilteredChannelInputWrapperaround the existing channel end.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReadFilter(Filter filter)Installs a read filter defining a transformation to be applied by thereadmethod of the channel end.voidaddReadFilter(Filter filter, int index)Installs a read filter defining a transformation to be applied by thereadmethod of the channel end at a specific index.FiltergetReadFilter(int index)Returns the read filter installed at the given index.intgetReadFilterCount()Returns the number of read filters currently installed.java.lang.Objectread()Reads a value from the channel.voidremoveReadFilter(int index)Removes the read filter installed at the given index.voidremoveReadFilter(Filter filter)Removes the first read filter (lowest index) matching the filter given as a parameter.-
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
-
-
-
-
Field Detail
-
filters
private FilterHolder filters
Set of read filters installed.
-
-
Constructor Detail
-
FilteredChannelInputWrapper
FilteredChannelInputWrapper(ChannelInput in)
Constructs a newFilteredChannelInputWrapperaround the existing channel end.- Parameters:
in- channel end to create the wrapper around.
-
-
Method Detail
-
read
public java.lang.Object read()
Description copied from class:ChannelInputWrapperReads a value from the channel.- Specified by:
readin interfaceChannelInput- Overrides:
readin classChannelInputWrapper- Returns:
- the value read.
- See Also:
ChannelInput
-
addReadFilter
public void addReadFilter(Filter filter)
Description copied from interface:ReadFilteredInstalls a read filter defining a transformation to be applied by thereadmethod 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:
addReadFilterin interfaceReadFiltered- Parameters:
filter- the filter to be installed; may not be null.
-
addReadFilter
public void addReadFilter(Filter filter, int index)
Description copied from interface:ReadFilteredInstalls a read filter defining a transformation to be applied by thereadmethod 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:
addReadFilterin interfaceReadFiltered- 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:ReadFilteredRemoves the first read filter (lowest index) matching the filter given as a parameter. The filter removed,r, will satisfy the conditionr.equals (filter). The remaining filters are shifted to close the gap in the index allocation.- Specified by:
removeReadFilterin interfaceReadFiltered- Parameters:
filter- the filter to be removed; may not be null.
-
removeReadFilter
public void removeReadFilter(int index)
Description copied from interface:ReadFilteredRemoves the read filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.- Specified by:
removeReadFilterin interfaceReadFiltered- Parameters:
index- zero-based index of the filter to be removed.
-
getReadFilter
public Filter getReadFilter(int index)
Description copied from interface:ReadFilteredReturns the read filter installed at the given index.- Specified by:
getReadFilterin interfaceReadFiltered- Parameters:
index- zero-based index of the filter to return.- Returns:
- the filter at that position.
-
getReadFilterCount
public int getReadFilterCount()
Description copied from interface:ReadFilteredReturns the number of read filters currently installed.- Specified by:
getReadFilterCountin interfaceReadFiltered
-
-