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

dk.rode.thesis.memento
Class MemorizableEnglishAlphabetSequence

java.lang.Object
  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>>

@Participant(value="Originator")
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.

Author:
Gunni Rode / rode.dk

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Sequence.State
 
Field Summary
 
Fields inherited from class dk.rode.thesis.meta.model.ArraySequence
elements, index
 
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence
state
 
Constructor Summary
MemorizableEnglishAlphabetSequence()
          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

MemorizableEnglishAlphabetSequence

public MemorizableEnglishAlphabetSequence()
No-arg constructor.


MemorizableEnglishAlphabetSequence

public MemorizableEnglishAlphabetSequence(EnglishAlphabetSequence sequence)
Copy constructor.

This sequence starts at the current index of sequence.

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

copy

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>>
Overrides:
copy in class EnglishAlphabetSequence
Returns:
A copy of this sequence; never null.

getMemorizableState

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>
Returns:
The memento; never null.

setMemorizableState

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>
Parameters:
memento - The memento supplying the state; cannot be null.
Throws:
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.