Class FilteredSharedChannelInputWrapper
java.lang.Object
org.jcsp.lang.ChannelInputWrapper
org.jcsp.util.filter.FilteredChannelInputWrapper
org.jcsp.util.filter.FilteredSharedChannelInputWrapper
- All Implemented Interfaces:
ChannelInput, Poisonable, SharedChannelInput, FilteredChannelInput, FilteredSharedChannelInput, ReadFiltered
public class FilteredSharedChannelInputWrapper
extends FilteredChannelInputWrapper
implements FilteredSharedChannelInput
This is wrapper for a
SharedChannelInput that adds
read filtering. Instances of this class can be safely used by
multiple concurrent processes.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ObjectThe object used for synchronization by the methods here to protect the readers from each other when manipulating the filters and reading data. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new wrapper for the given channel input end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReadFilter(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.getReadFilter(int index) Returns the read filter installed at the given index.intReturns the number of read filters currently installed.read()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 ChannelInputWrapper
endRead, poison, startReadMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelInput
endRead, startReadMethods inherited from interface Poisonable
poison
-
Field Details
-
synchObject
The object used for synchronization by the methods here to protect the readers from each other when manipulating the filters and reading data.
-
-
Constructor Details
-
Method Details
-
read
Description copied from class:ChannelInputWrapperReads a value from the channel.- Specified by:
readin interfaceChannelInput- Overrides:
readin classFilteredChannelInputWrapper- Returns:
- the value read.
- See Also:
-
addReadFilter
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- Overrides:
addReadFilterin classFilteredChannelInputWrapper- Parameters:
filter- the filter to be installed; may not be null.
-
addReadFilter
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- Overrides:
addReadFilterin classFilteredChannelInputWrapper- Parameters:
filter- the filter to be installed; may not be null.index- the zero based index; may not be negative.
-
removeReadFilter
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- Overrides:
removeReadFilterin classFilteredChannelInputWrapper- 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- Overrides:
removeReadFilterin classFilteredChannelInputWrapper- Parameters:
index- zero-based index of the filter to be removed.
-
getReadFilter
Description copied from interface:ReadFilteredReturns the read filter installed at the given index.- Specified by:
getReadFilterin interfaceReadFiltered- Overrides:
getReadFilterin classFilteredChannelInputWrapper- 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- Overrides:
getReadFilterCountin classFilteredChannelInputWrapper
-