Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.observer
Class CorrelatedSequenceObserver

java.lang.Object
  extended by dk.rode.thesis.observer.CorrelatedSequenceObserver
All Implemented Interfaces:
SequenceObserver<Sequence.State>

@Participant(value="ConcreteObserver")
public class CorrelatedSequenceObserver
extends Object
implements SequenceObserver<Sequence.State>

A correlated sequence observer correlates the behaviour of an observable sequence with another (perhaps observable) Sequence.

When Sequence.next() is invoked on the observed sequence, next is invoked on the correlated sequence. The same is true for Sequence.reset(), either if implicit in form of a bounded sequence that wraps, or because the reset() method was explicitly invoked.

Author:
Gunni Rode / rode.dk

Field Summary
private  Sequence<?> sequence
          The correlated sequence.
 
Constructor Summary
CorrelatedSequenceObserver(Sequence<?> sequence)
          Constructor.
 
Method Summary
 void sequenceEvent(Sequence<?> sequence, Sequence.State state)
          Notification method that is invoked when the sequence supplied as sequence has changed its state to state.
 String toString()
          Returns the string representation of this observer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sequence

private final Sequence<?> sequence
The correlated sequence.

Never null.

Constructor Detail

CorrelatedSequenceObserver

public CorrelatedSequenceObserver(Sequence<?> sequence)
Constructor.

Parameters:
sequence - The sequence to correlate; cannot be null.
Throws:
NullPointerException - If sequence is null.
Method Detail

sequenceEvent

public void sequenceEvent(Sequence<?> sequence,
                          Sequence.State state)
Description copied from interface: SequenceObserver
Notification method that is invoked when the sequence supplied as sequence has changed its state to state.

The type of sequence is not defined; it cannot be assumed observable, or even of the type this observer was attached to; it might be adapted, decorated, composite, or proxied.

Specified by:
sequenceEvent in interface SequenceObserver<Sequence.State>
Parameters:
sequence - This sequence; cannot be null.
state - The current (new) aspect; cannot be null.

toString

public String toString()
Returns the string representation of this observer.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.