Package org.refcodes.serial.ext.observer
Class ObservableSegmentDecorator<DECORATEE extends org.refcodes.serial.Segment>
java.lang.Object
org.refcodes.serial.ext.observer.ObservableSegmentDecorator<DECORATEE>
- Type Parameters:
DECORATEE- The type of the observed decoratee in question.
- All Implemented Interfaces:
Serializable,org.refcodes.mixin.DecorateeAccessor<DECORATEE>,org.refcodes.mixin.LengthAccessor,org.refcodes.mixin.Schemable<org.refcodes.serial.SerialSchema>,org.refcodes.observer.Observable<TransmissionObserver<DECORATEE>>,org.refcodes.serial.DecoratorSegment<DECORATEE>,ObservableSegment<DECORATEE>,ObservableTransmission<DECORATEE>,org.refcodes.serial.Segment,org.refcodes.serial.Transmission
public class ObservableSegmentDecorator<DECORATEE extends org.refcodes.serial.Segment>
extends Object
implements ObservableSegment<DECORATEE>, org.refcodes.serial.DecoratorSegment<DECORATEE>
The
ObservableSegment class enriches a Segment decoratee with
observer functionality as of the ObservableSegment interface. In case
the decoratee was updated as of
receiveFrom(InputStream, OutputStream) or
Segment.fromTransmission(Sequence) or the like, a TransmissionEvent
is fired.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.DecorateeAccessor
org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE extends Object,B extends org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE, B>>, org.refcodes.mixin.DecorateeAccessor.DecorateeMutator<DECORATEE extends Object>, org.refcodes.mixin.DecorateeAccessor.DecorateeProperty<DECORATEE extends Object> Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthPropertyNested classes/interfaces inherited from interface org.refcodes.serial.Segment
org.refcodes.serial.Segment.SegmentMixinNested classes/interfaces inherited from interface org.refcodes.serial.Transmission
org.refcodes.serial.Transmission.TransmissionMixin -
Constructor Summary
ConstructorsConstructorDescriptionObservableSegmentDecorator(DECORATEE aDecoratee) Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using a defaultExecutorServiceand dispatching events in sequentially (as ofExecutionStrategy.SEQUENTIAL).ObservableSegmentDecorator(DECORATEE aDecoratee, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using the providedExecutorServicewhen dispatching events in parallel (as ofExecutionStrategy.PARALLELandExecutionStrategy.JOIN) and using the givenExecutionStrategywhen dispatching the events.ObservableSegmentDecorator(DECORATEE aDecoratee, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using the providedExecutionStrategywhen dispatching the events. -
Method Summary
Modifier and TypeMethodDescriptionintfromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset) intbooleanhasObserverSubscription(TransmissionObserver<DECORATEE> aObserver) voidreceiveFrom(InputStream aInputStream, OutputStream aReturnStream) booleansubscribeObserver(TransmissionObserver<DECORATEE> aObserver) org.refcodes.serial.SerialSchematoSchema()org.refcodes.serial.Sequenceorg.refcodes.struct.SimpleTypeMapvoidtransmitTo(OutputStream aOutputStream, InputStream aReturnStream) booleanunsubscribeObserver(TransmissionObserver<DECORATEE> aObserver) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFromMethods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
-
Constructor Details
-
ObservableSegmentDecorator
Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using a defaultExecutorServiceand dispatching events in sequentially (as ofExecutionStrategy.SEQUENTIAL).- Parameters:
aDecoratee- The decoratee to be wrapped by the observable decorator.
-
ObservableSegmentDecorator
public ObservableSegmentDecorator(DECORATEE aDecoratee, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using the providedExecutionStrategywhen dispatching the events.- Parameters:
aDecoratee- The decoratee to be wrapped by the observable decorator.aExecutionStrategy- the execution strategy to use when dispatching events.
-
ObservableSegmentDecorator
public ObservableSegmentDecorator(DECORATEE aDecoratee, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Constructs aObservableSegmentwrapping the givenSegmentdecoratee and using the providedExecutorServicewhen dispatching events in parallel (as ofExecutionStrategy.PARALLELandExecutionStrategy.JOIN) and using the givenExecutionStrategywhen dispatching the events.- Parameters:
aDecoratee- The decoratee to be wrapped by the observable decorator.aExecutorService- the executor service to use when dispatching events.aExecutionStrategy- the execution strategy to use when dispatching events.
-
-
Method Details
-
fromTransmission
public int fromTransmission(org.refcodes.serial.Sequence aSequence, int aOffset) throws org.refcodes.serial.TransmissionException - Specified by:
fromTransmissionin interfaceorg.refcodes.serial.Segment- Throws:
org.refcodes.serial.TransmissionException
-
receiveFrom
public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, org.refcodes.serial.TransmissionException - Specified by:
receiveFromin interfaceorg.refcodes.serial.Segment- Throws:
IOExceptionorg.refcodes.serial.TransmissionException
-
getLength
public int getLength()- Specified by:
getLengthin interfaceorg.refcodes.mixin.LengthAccessor- Specified by:
getLengthin interfaceorg.refcodes.serial.Transmission
-
toSequence
public org.refcodes.serial.Sequence toSequence()- Specified by:
toSequencein interfaceorg.refcodes.serial.Transmission
-
transmitTo
- Specified by:
transmitToin interfaceorg.refcodes.serial.Transmission- Throws:
IOException
-
toSchema
public org.refcodes.serial.SerialSchema toSchema()- Specified by:
toSchemain interfaceorg.refcodes.mixin.Schemable<DECORATEE extends org.refcodes.serial.Segment>- Specified by:
toSchemain interfaceorg.refcodes.serial.Transmission
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()- Specified by:
toSimpleTypeMapin interfaceorg.refcodes.serial.Transmission
-
getDecoratee
- Specified by:
getDecorateein interfaceorg.refcodes.mixin.DecorateeAccessor<DECORATEE extends org.refcodes.serial.Segment>
-
hasObserverSubscription
- Specified by:
hasObserverSubscriptionin interfaceorg.refcodes.observer.Observable<DECORATEE extends org.refcodes.serial.Segment>
-
subscribeObserver
- Specified by:
subscribeObserverin interfaceorg.refcodes.observer.Observable<DECORATEE extends org.refcodes.serial.Segment>
-
unsubscribeObserver
- Specified by:
unsubscribeObserverin interfaceorg.refcodes.observer.Observable<DECORATEE extends org.refcodes.serial.Segment>
-