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

dk.rode.thesis.observer
Class ProbeSequenceObserver

java.lang.Object
  extended by dk.rode.thesis.observer.ProbeSequenceObserver

@Participant(value="ConcreteObserver")
public class ProbeSequenceObserver
extends Object

A probe sequence observer prints the internal attributes that has changed for a given sequence since the last time the observer was notified about that sequence, based on equality using equals(Object) (and hashCode()).

Implementation notes:
A probe observer uses the Executor annotation to specify the observer methods, and can thus be used with the ObserverManager type or any AnnotatedObserversSequence implementation. It cannot, however, be used an observer for sequences expecting a SequenceObserver type.

Author:
Gunni Rode / rode.dk

Field Summary
private  Map<Sequence<?>,Sequence<?>> sequences
          The map of currently probed sequences.
 
Constructor Summary
ProbeSequenceObserver()
          No-arg constructor.
 
Method Summary
(package private) static void externalProbe(Sequence<?> sequence, Sequence.State state)
          Probe method that will only be invoked by an observable ReversiblePrimeSequence instance (decorated by the AnnotatedObserversSequenceDecorator type).
(package private)  void internalProbe(Sequence<?> sequence, Sequence.State state)
          Probes the sequence supplied as sequence, and logs all attributes that has changed value (based on equals(Object)) since the last time this method was invoked with the same sequence (based on equals(Object)) as the first argument.
 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

sequences

private Map<Sequence<?>,Sequence<?>> sequences
The map of currently probed sequences.

Never null.

Constructor Detail

ProbeSequenceObserver

public ProbeSequenceObserver()
No-arg constructor.

Method Detail

externalProbe

@Executor(value=ReversiblePrimeSequence.class)
static void externalProbe(Sequence<?> sequence,
                                                                     Sequence.State state)
Probe method that will only be invoked by an observable ReversiblePrimeSequence instance (decorated by the AnnotatedObserversSequenceDecorator type).

Parameters:
sequence - The sequence; never null.
state - The sequence state; never null.

internalProbe

@Executor
void internalProbe(Sequence<?> sequence,
                            Sequence.State state)
             throws Exception
Probes the sequence supplied as sequence, and logs all attributes that has changed value (based on equals(Object)) since the last time this method was invoked with the same sequence (based on equals(Object)) as the first argument.

Any context may use this probe method.

Parameters:
sequence - The sequence to probe; cannot be null.
state - The current state of sequence; can be null.
Throws:
Exception - If the probing fails.

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.