|
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>
E
- The type of values delivered by this sequence.public abstract class AbstractSequence<E>
An abstract sequence implements the basic traits of
the Sequence
interface.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
protected Sequence.State |
state
The internal state. |
Constructor Summary | |
---|---|
protected |
AbstractSequence()
No-arg constructor, which reset this sequence
and then initialise the internal state to Sequence.State.START . |
protected |
AbstractSequence(boolean reset)
Constructor, which reset this sequence
if reset is true and then initialises the internal
state to Sequence.State.START . |
protected |
AbstractSequence(Sequence<? super E> sequence)
Copy constructor. |
Method Summary | |
---|---|
StringablePolicy<? super Sequence<E>> |
getStringablePolicy(StringablePolicy<? super Sequence<E>> policy)
Always return a non-null policy: policy is not null: policy is returned. |
void |
reset()
Resets this sequence to start over if it is consistent. |
Sequence.State |
state()
Returns the internal state of this sequence. |
String |
toString()
Returns the default string representation specified by the toString(StringablePolicy) method. |
CharSequence |
toString(StringablePolicy<? super Sequence<E>> policy)
Returns a char sequence representation of this stringable object using the format determined by policy or the
default policy
in case policy is null. |
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 |
---|
bounded, consistent, copy, current, next, unique |
Field Detail |
---|
protected Sequence.State state
Never null.
Constructor Detail |
---|
protected AbstractSequence()
reset
this sequence
and then initialise the internal state to Sequence.State.START
. Note, that this sequence may be reset before completely initialised!
protected AbstractSequence(boolean reset)
reset
this sequence
if reset
is true and then initialises the internal
state to Sequence.State.START
. Note, that this sequence can be reset before completely initialised!
reset
- True to reset.protected AbstractSequence(Sequence<? super E> sequence)
The state of sequence
is set for this sequence.
sequence
- The sequence to copy; cannot be null.
NullPointerException
- If sequence
is null.Method Detail |
---|
public StringablePolicy<? super Sequence<E>> getStringablePolicy(StringablePolicy<? super Sequence<E>> policy)
Stringable
policy
is not null: policy
is returned.
policy
is null: a default, non-null policy is returned.
getStringablePolicy
in interface Stringable<Sequence<E>>
policy
- The supplied policy; can be null.
Stringable.toString(StringablePolicy)
public void reset()
Sequence
If this sequence is consistent
, the
sequence will restart.
reset
in interface Sequence<E>
public Sequence.State state()
Sequence
state
in interface Sequence<E>
public String toString()
toString(StringablePolicy)
method.
toString
in class Object
public CharSequence toString(StringablePolicy<? super Sequence<E>> policy)
Stringable
policy
or the
default
policy
in case policy
is null.
In Foo
, a typical implementation of this method
could be:
public CharSequence toString(StringablePolicy<? super Foo> policy) { return this.There are two approaches to formatting this stringable object into a char sequence representation:getStringablePolicy
(policy).toString
(this); }
policy
decide the entire format,
as in the Foo
example above; or
policy
to format part of the overall
representation, for example letting this method append
certain text regardless of the policy used.
StringablePolicy.toString(Object)
method, for
example in case multiple stringable objects should be formatted
into an overall representation.
In case an implementation uses the approach from bullet 2), care
must be take to respect the policy hints
so the overall format remains meaningful.
toString
in interface Stringable<Sequence<E>>
policy
- The policy to dictate the formatting; can be null, in
which case the result of toString
method
is returned.
StringablePolicy.Type
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |