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

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object dk.rode.thesis.meta.model.AbstractSequence<E> dk.rode.thesis.composite.AbstractCompositeSequence<E>
E
 The type of values delivered by this composite sequence.@Participant(value="Composite") public abstract class AbstractCompositeSequence<E>
An abstract composite sequence implements the basic traits
of the CompositeSequence
interface.
This implementation is not threadsafe.
Nested Class Summary 

Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence 

Sequence.State 
Field Summary  

protected List<Sequence<? extends E>> 
sequences
The sequences associated with this sequence, in order. 
private CompositeStrategy 
strategy
The strategy used for traversal starting from this composite unless a strategy is specifically requested. 
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence 

state 
Constructor Summary  

AbstractCompositeSequence()
Noarg constructor. 

AbstractCompositeSequence(CompositeSequence<? extends E> sequence)
Copy constructor, which also copies associated sequences. 

AbstractCompositeSequence(CompositeStrategy strategy,
Sequence<? extends E>... sequences)
Constructor. 
Method Summary  

boolean 
addSequence(Sequence<? extends E> sequence)
Associates the sequence supplied
as sequence to this composite sequence, if
not already. 

boolean 
bounded()
Returns true if this sequence is bounded, i.e. 

protected void 
calculateNextState()
Calculates a "meaningful" state based on all associated sequences: if all are reset, this sequence is reset. 

boolean 
consistent()
Returns true if this sequence is consistent, i.e. deliver the same values, in order, after restart or reset . 

CompositeStrategy 
getCompositeStrategy()
Return the current strategy used by
this composite sequence to traverse the associated sequence
graph. 

List<Sequence<? extends E>> 
getSequences()
Returns the sequences currently
associated with this composite sequence, in order. 


getSequences(Class<V> clazz)
Returns the sequences currently
associated with this composite sequence, in order,
assignable to the type supplied as clazz . 

List<Sequence<? extends E>> 
getSequences(CompositeStrategy strategy,
boolean includeSelf,
Boolean type)
Returns the sequences currently
reachable from this composite sequence, in the
order specified by strategy . 


getSequences(CompositeStrategy strategy,
boolean includeSelf,
Boolean type,
Class<V> clazz)
Returns the sequences currently
reachable from this composite sequence, in the order
specified by strategy . 

Iterator<Sequence<? extends E>> 
iterator()


boolean 
removeSequence(Sequence<?> sequence)
Removes the sequence supplied
as sequence from this composite sequence, if
associated. 

void 
reset()
Resets this sequence to start over if it is consistent. 

void 
setCompositeStrategy(CompositeStrategy policy)
Sets the current strategy used by
this composite sequence to traverse the associated sequence
graph to strategy . 

int 
size()
Returns the number of sequences associated to this composite sequence. 

boolean 
unique()
Returns false. 
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence 

getStringablePolicy, state, toString, toString 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Methods inherited from interface dk.rode.thesis.meta.model.Sequence 

copy, current, next, state 
Methods inherited from interface dk.rode.thesis.strategy.Stringable 

getStringablePolicy, toString 
Field Detail 

protected final List<Sequence<? extends E>> sequences
Is a random access list for fast traversal.
Never null, but can be null.
private CompositeStrategy strategy
Never null.
Constructor Detail 

public AbstractCompositeSequence()
The CompositeStrategy.DEFAULT
strategy is used
for traversal.
public AbstractCompositeSequence(CompositeSequence<? extends E> sequence)
sequence
 The composite sequence to copy; cannot be null.
NullPointerException
 If sequence
is null.public AbstractCompositeSequence(CompositeStrategy strategy, Sequence<? extends E>... sequences)
strategy
 The traversal strategy; can be null, in which
case CompositeStrategy.DEFAULT
is used.sequences
 Sequences to add to this composite, if any; can be
null. Null entries are ignored.Method Detail 

public boolean addSequence(Sequence<? extends E> sequence)
CompositeSequence
sequence
supplied
as sequence
to this composite sequence, if
not already. If already added, this method does nothing.
addSequence
in interface CompositeSequence<E>
sequence
 The sequence to add; cannot be null.
sequence
was added, false if not,
i.e. if already added.CompositeSequence.removeSequence(Sequence)
public boolean bounded()
Sequence
The same type of sequence may represent both bounded and
unbounded sequences and the behaviour is determined and fixed
at construction time.
Bounded sequences will restart if they deliver
consistent
values.
bounded
in interface Sequence<E>
Sequence.unique()
protected void calculateNextState()
Subclasses should invoke this method in their next()
implementation after the individual sequences have been advanced.
public boolean consistent()
Sequence
reset
.
Only bounded
consistent sequences will restart.
Consistent sequences need not deliver unique
sequence values.
Instances of the same type of sequences are always consistent or inconsistent; it is determined at design time, not construction time.
consistent
in interface Sequence<E>
public CompositeStrategy getCompositeStrategy()
CompositeSequence
strategy
used by
this composite sequence to traverse the associated sequence
graph.
getCompositeStrategy
in interface CompositeSequence<E>
public List<Sequence<? extends E>> getSequences()
CompositeSequence
sequences
currently
associated with this composite sequence, in order. Modifying the returned collection will not affect this sequence.
getSequences
in interface CompositeSequence<E>
public <V extends Sequence<?>> List<V> getSequences(Class<V> clazz)
CompositeSequence
sequences
currently
associated with this composite sequence, in order,
assignable to the type supplied as clazz
.
Invoking this method with the Sequence
interface
corresponds to invoking CompositeSequence.getSequences()
.
Modifying the returned collection will not affect this sequence.
getSequences
in interface CompositeSequence<E>
V
 The type of applicable sequences.clazz
 The (super)class of sequences to include; cannot be null.
clazz
; never null, but can be
empty.public List<Sequence<? extends E>> getSequences(CompositeStrategy strategy, boolean includeSelf, Boolean type)
CompositeSequence
sequences
currently
reachable from this composite sequence, in the
order specified by strategy
.
This sequence is included in the returned list if
includeSelf
is true and it matches type
;
type
determines the types of sequences to include in
the returned list:
TRUE
: only composite sequences ("nodes").
FALSE
: only noncomposite sequences ("leafs").
If strategy
is null, the default
strategy for this sequence is used.
Modifying the returned collection will not affect this sequence.
getSequences
in interface CompositeSequence<E>
strategy
 The strategy dictating the traversal; can be null.includeSelf
 True to include this composite sequence in the
returned list (if it matches type
),
false to exclude.type
 The type of sequences to include in the returned
list; can be null.
public <V extends Sequence<?>> List<V> getSequences(CompositeStrategy strategy, boolean includeSelf, Boolean type, Class<V> clazz)
CompositeSequence
sequences
currently
reachable from this composite sequence, in the order
specified by strategy
. Each sequence included
in the returned list is assignable to the type supplied
as clazz
.
This sequence is included in the returned list if it
matches clazz
and type
; type
determines
the types of sequences to include in the returned list:
TRUE
: only composite sequences ("nodes").
FALSE
: only noncomposite sequences ("leafs").
If strategy
is null, the default
strategy for this sequence is used.
Modifying the returned collection will not affect this sequence.
getSequences
in interface CompositeSequence<E>
V
 The type of applicable sequences.strategy
 The strategy dictating the traversal; can be null.includeSelf
 True to include this composite sequence in the
returned list (if it matches type
and
clazz
), false to exclude.type
 The type of sequences to include in the returned
list; can be null.clazz
 The (super)class of sequences to include; cannot be null.
clazz
; never null, but can be
empty.public Iterator<Sequence<? extends E>> iterator()
iterator
in interface Iterable<Sequence<? extends E>>
public boolean removeSequence(Sequence<?> sequence)
CompositeSequence
sequence
supplied
as sequence
from this composite sequence, if
associated. If not associated, this method does nothing.
removeSequence
in interface CompositeSequence<E>
sequence
 The sequence to remove; cannot be null.
sequence
was removed, false if not,
i.e. if not previously added.CompositeSequence.addSequence(Sequence)
public void reset()
Sequence
If this sequence is consistent
, the
sequence will restart.
reset
in interface Sequence<E>
reset
in class AbstractSequence<E>
public void setCompositeStrategy(CompositeStrategy policy)
CompositeSequence
strategy
used by
this composite sequence to traverse the associated sequence
graph to strategy
.
setCompositeStrategy
in interface CompositeSequence<E>
policy
 The strategy; can be null, in which case the
default strategy is used.public int size()
CompositeSequence
size
in interface CompositeSequence<E>
public boolean unique()
unique
in interface Sequence<E>
Sequence.consistent()

Gunni Rode / rode.dk  
PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 