|
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.decorator.SequenceDecorator<String> dk.rode.thesis.decorator.AppenderDecorator
@Participant(value="ConcreteDecorator") public class AppenderDecorator
An appender decorator returns the String value
from a decorated sequence prefixed and/or postfixed with
values supplied at construction time, respectively. Given
the prefix and postfix values xx
and zz
,
the value returned will thus be xxYYzz
, where
YY
is the value returned by the decorated sequence.
Only sequences returning strings can be decorated.
The default stringable policy used is DecoratedPolicy.HIDDEN
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
private CharSequence |
postfix
Postfix to any value returned by the decorated sequence. |
private CharSequence |
prefix
Prefix to any value returned by the decorated sequence. |
Fields inherited from class dk.rode.thesis.decorator.SequenceDecorator |
---|
sequence |
Constructor Summary | |
---|---|
AppenderDecorator(Sequence<String> sequence,
CharSequence prefix,
CharSequence postfix)
Constructor. |
Method Summary | |
---|---|
AppenderDecorator |
copy()
Returns a copy of this sequence that will start at the same sequence index as this sequence. |
String |
current()
Returns the current element from this sequence. |
private static String |
enclose(CharSequence prefix,
CharSequence value,
CharSequence postfix)
Returns a string having one of the following formats depending on whether prefix and
postfix are null, respectively:
value : prefix and postfix are null. |
String |
next()
Returns the next element from this sequence. |
Methods inherited from class dk.rode.thesis.decorator.SequenceDecorator |
---|
bounded, consistent, equals, getSequence, getStringablePolicy, hashCode, reset, state, toString, toString, unique |
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, reset, state, unique |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
private final CharSequence postfix
Can be null, i.e. not used.
private final CharSequence prefix
Can be null, i.e. not used.
Constructor Detail |
---|
public AppenderDecorator(@Participant(value="ConcreteComponent") Sequence<String> sequence, CharSequence prefix, CharSequence postfix)
sequence
- The sequence to decorate; cannot be null.prefix
- The prefix to use; null means none.postfix
- The postfix to use; null means none.
NullPointerException
- If sequence
is null.Method Detail |
---|
public AppenderDecorator copy()
Sequence
copy
in interface Sequence<String>
copy
in interface Copyable<Sequence<String>>
public String current()
Sequence
This method can be invoked even if Sequence.next()
has not been invoked yet, thus delivering the initial
value of this sequence.
current
in interface Sequence<String>
current
in class SequenceDecorator<String>
private static final String enclose(CharSequence prefix, CharSequence value, CharSequence postfix)
prefix
and
postfix
are null, respectively:
value
: prefix
and postfix
are null.
prefix
+ value
: postfix
is null.
value
+ postfix
: prefix
is null.
prefix
+ value
+ postfix
: neither is null.
prefix
- The prefix, if any; can be null.value
- The value; cannot be null.postfix
- The postfix, if any; can be null.
public String next()
Sequence
next
in interface Sequence<String>
next
in class SequenceDecorator<String>
Sequence.current()
,
Sequence.state()
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |