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

Class MemorizableEnglishAlphabetSequence

  extended by dk.rode.thesis.meta.model.AbstractSequence<E>
      extended by dk.rode.thesis.meta.model.ArraySequence<String>
          extended by dk.rode.thesis.meta.model.EnglishAlphabetSequence
              extended by dk.rode.thesis.memento.MemorizableEnglishAlphabetSequence
All Implemented Interfaces:
MemorizableSequence<String>, Sequence<String>, Copyable<Sequence<String>>, StrictCopyable<Sequence<String>>, Stringable<Sequence<String>>

public class MemorizableEnglishAlphabetSequence
extends EnglishAlphabetSequence
implements MemorizableSequence<String>

A memorizable alphabet sequence for letters in the English alphabet, i.e. a though z, lower-cased, that can save and restore its internal state in form of mementos.

Implementation notes:
The mementos created are regular SequenceMemento instances, not GuardedSequenceMemento instances as in the RangeSequence class.

Gunni Rode / rode.dk

Nested Class Summary
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Field Summary
Fields inherited from class dk.rode.thesis.meta.model.ArraySequence
elements, index
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence
Constructor Summary
          No-arg constructor.
MemorizableEnglishAlphabetSequence(EnglishAlphabetSequence sequence)
          Copy constructor.
Method Summary
 MemorizableEnglishAlphabetSequence copy()
          Returns a copy of this sequence that will start at the same sequence index as this sequence.
 SequenceMemento<String> getMemorizableState()
          Returns a sequence memento representing the current state of this sequence.
 void setMemorizableState(SequenceMemento<String> memento)
          Updates this sequence to the state supplied as memento.
Methods inherited from class dk.rode.thesis.meta.model.ArraySequence
bounded, consistent, current, equals, hashCode, next, reset, size, unique
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence
getStringablePolicy, state, toString, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface dk.rode.thesis.meta.model.Sequence
bounded, consistent, current, next, reset, state, unique
Methods inherited from interface dk.rode.thesis.strategy.Stringable
getStringablePolicy, toString

Constructor Detail


public MemorizableEnglishAlphabetSequence()
No-arg constructor.


public MemorizableEnglishAlphabetSequence(EnglishAlphabetSequence sequence)
Copy constructor.

This sequence starts at the current index of sequence.

sequence - The sequence to copy; cannot be null.
NullPointerException - If sequence is null.
Method Detail


public MemorizableEnglishAlphabetSequence copy()
Description copied from interface: Sequence
Returns a copy of this sequence that will start at the same sequence index as this sequence.

Specified by:
copy in interface Sequence<String>
Specified by:
copy in interface Copyable<Sequence<String>>
copy in class EnglishAlphabetSequence
A copy of this sequence; never null.


public SequenceMemento<String> getMemorizableState()
Description copied from interface: MemorizableSequence
Returns a sequence memento representing the current state of this sequence.

Specified by:
getMemorizableState in interface MemorizableSequence<String>
The memento; never null.


public void setMemorizableState(SequenceMemento<String> memento)
                         throws MemorizableException
Description copied from interface: MemorizableSequence
Updates this sequence to the state supplied as memento.

Specified by:
setMemorizableState in interface MemorizableSequence<String>
memento - The memento supplying the state; cannot be null.
MemorizableException - If the update fails, e.g. illegal memento state for this sequence, or illegal memento type.

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.