Package org.jcsp.util.filter
Class FilteredAltingChannelInput
java.lang.Object
org.jcsp.lang.Guard
org.jcsp.lang.AltingChannelInput
org.jcsp.lang.AltingChannelInputWrapper
org.jcsp.util.filter.FilteredAltingChannelInput
- All Implemented Interfaces:
ChannelInput
,Poisonable
,FilteredChannelInput
,ReadFiltered
public class FilteredAltingChannelInput
extends AltingChannelInputWrapper
implements FilteredChannelInput
Implements an
AltingChannelInput
channel end that also supports read filters.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FilterHolder
Holds the filters installed for the read end of this channel. -
Constructor Summary
ConstructorsConstructorDescriptionFilteredAltingChannelInput
(AltingChannelInput altingChannelInput) Constructs a new channel end that supports filtering by wrapping up an existing channel end. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReadFilter
(Filter filter) Installs a read filter defining a transformation to be applied by theread
method of the channel end.void
addReadFilter
(Filter filter, int index) Installs a read filter defining a transformation to be applied by theread
method of the channel end at a specific index.getReadFilter
(int index) Returns the read filter installed at the given index.int
Returns the number of read filters currently installed.read()
Read an Object from the channel.void
removeReadFilter
(int index) Removes the read filter installed at the given index.void
removeReadFilter
(Filter filter) Removes the first read filter (lowest index) matching the filter given as a parameter.Methods inherited from class org.jcsp.lang.AltingChannelInputWrapper
endRead, getChannel, pending, poison, setChannel, 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 Details
-
filters
Holds the filters installed for the read end of this channel.
-
-
Constructor Details
-
FilteredAltingChannelInput
FilteredAltingChannelInput(AltingChannelInput altingChannelInput) Constructs a new channel end that supports filtering by wrapping up an existing channel end.- Parameters:
altingChannelInput
- the existing channel end.
-
-
Method Details
-
read
Description copied from class:AltingChannelInputWrapper
Read an Object from the channel.- Specified by:
read
in interfaceChannelInput
- Overrides:
read
in classAltingChannelInputWrapper
- Returns:
- the object read from the channel
-
addReadFilter
Description copied from interface:ReadFiltered
Installs a read filter defining a transformation to be applied by theread
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 interfaceReadFiltered
- Parameters:
filter
- the filter to be installed; may not be null.
-
addReadFilter
Description copied from interface:ReadFiltered
Installs a read filter defining a transformation to be applied by theread
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 interfaceReadFiltered
- 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:ReadFiltered
Removes 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:
removeReadFilter
in interfaceReadFiltered
- 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 interfaceReadFiltered
- Parameters:
index
- zero-based index of the filter to be removed.
-
getReadFilter
Description copied from interface:ReadFiltered
Returns the read filter installed at the given index.- Specified by:
getReadFilter
in 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:ReadFiltered
Returns the number of read filters currently installed.- Specified by:
getReadFilterCount
in interfaceReadFiltered
-