Class FilteredSharedChannelOutputWrapper
java.lang.Object
org.jcsp.lang.ChannelOutputWrapper
org.jcsp.util.filter.FilteredChannelOutputWrapper
org.jcsp.util.filter.FilteredSharedChannelOutputWrapper
- All Implemented Interfaces:
ChannelOutput, Poisonable, SharedChannelOutput, FilteredChannelOutput, FilteredSharedChannelOutput, WriteFiltered
public class FilteredSharedChannelOutputWrapper
extends FilteredChannelOutputWrapper
implements FilteredSharedChannelOutput
This is wrapper for a
SharedChannelOutput that adds
write filtering. Instances of this class can be safely used by
multiple concurrent processes.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ObjectThe synchronization object to protect the writers from each other when they read data or update the write filters. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new wrapper for the given channel output end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWriteFilter(Filter filter) Installs a write filter defining a transformation to be applied by thewritemethod of the channel end.voidaddWriteFilter(Filter filter, int index) Installs a write filter defining a transformation to be applied by thewritemethod of the channel end at a specific index.getWriteFilter(int index) Returns the write filter installed at the given index.intReturns the number of write filters currently installed.voidremoveWriteFilter(int index) Removes the write filter installed at the given index.voidremoveWriteFilter(Filter filter) Removes the first write filter (lowest index) matching the filter given as a parameter.voidWrites a value to the channel.Methods inherited from class ChannelOutputWrapper
poisonMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Poisonable
poison
-
Field Details
-
synchObject
The synchronization object to protect the writers from each other when they read data or update the write filters.
-
-
Constructor Details
-
Method Details
-
write
Description copied from class:ChannelOutputWrapperWrites a value to the channel.- Specified by:
writein interfaceChannelOutput- Overrides:
writein classFilteredChannelOutputWrapper- Parameters:
data- the value to write.- See Also:
-
addWriteFilter
Description copied from interface:WriteFilteredInstalls a write filter defining a transformation to be applied by thewritemethod 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:
addWriteFilterin interfaceWriteFiltered- Overrides:
addWriteFilterin classFilteredChannelOutputWrapper- Parameters:
filter- the filter to be installed; may not be null.
-
addWriteFilter
Description copied from interface:WriteFilteredInstalls a write filter defining a transformation to be applied by thewritemethod 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:
addWriteFilterin interfaceWriteFiltered- Overrides:
addWriteFilterin classFilteredChannelOutputWrapper- Parameters:
filter- the filter to be installed; may not be null.index- the zero based index; may not be negative.
-
removeWriteFilter
Description copied from interface:WriteFilteredRemoves the first write 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:
removeWriteFilterin interfaceWriteFiltered- Overrides:
removeWriteFilterin classFilteredChannelOutputWrapper- Parameters:
filter- the filter to be removed; may not be null.
-
removeWriteFilter
public void removeWriteFilter(int index) Description copied from interface:WriteFilteredRemoves the write filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.- Specified by:
removeWriteFilterin interfaceWriteFiltered- Overrides:
removeWriteFilterin classFilteredChannelOutputWrapper- Parameters:
index- zero-based index of the filter to be removed.
-
getWriteFilter
Description copied from interface:WriteFilteredReturns the write filter installed at the given index.- Specified by:
getWriteFilterin interfaceWriteFiltered- Overrides:
getWriteFilterin classFilteredChannelOutputWrapper- Parameters:
index- zero-based index of the filter to return.- Returns:
- the filter at that position.
-
getWriteFilterCount
public int getWriteFilterCount()Description copied from interface:WriteFilteredReturns the number of write filters currently installed.- Specified by:
getWriteFilterCountin interfaceWriteFiltered- Overrides:
getWriteFilterCountin classFilteredChannelOutputWrapper
-