|
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 |
P
- The type of the additional parameter to this visitor's methods.
Use Void
for visitors that do not need an additional
parameter.@Participant(value="Visitor") public interface SequenceValueVisitor<P>
A sequence value visitor visits a sequence
based on the type of values it deliver, for example Integer
or Date
.
For the type X, the general rule for the corresponding visitation
method signature is visitNameValued(Sequence<X>, Object)
, where
Name
is the simple name of X
, for example
visitLongValued(Sequence
for the java.lang.Long
type. In case no such visitation method
can be found, the SequenceVisitor.visitUnknown(Sequence, Object)
}
method is used.
Implementation notes:
Gamma et al. suggest the possibility of using visit
as an
overloaded visitation method name [Gamma95, p.337]. For this visitor
this is not possible, since we differentiate on the type
parameter used for the sequence argument, for example Long
and Date
, not the actual Sequence
type itself. However,
type parameters are erased at runtime, so it is only the method
name that actually distinguishes the different visitation methods:
at runtime, they all get a raw Sequence
instance. Ordinary
polymorhpism can naturally still be applied, though, for overloaded
method names.
The visitation methods all accept an argument of type Sequence
,
not ValueVisitableSequence
. This offers more flexibility and is
reasonable since visitable sequences generally do not offer new sequence
state, merely new behaviour. It also allows visitation to decorated,
proxied, adapted, and composite sequences. Hence, the normal
Sequence
interface must be used to perform the actual
visitation logic as not to break encapsulation (see [Gamma95, p.337]).
SequenceValueScanner
,
SequenceTypeVisitor
Method Summary | |
---|---|
void |
visitDateValued(Sequence<Date> sequence,
P argument)
Visits a sequence that delivers Date
sequence values. |
void |
visitIntegerValued(Sequence<Integer> sequence,
P argument)
Visits a sequence that delivers Integer
sequence values. |
void |
visitLongValued(Sequence<Long> sequence,
P argument)
Visits a sequence that delivers Long
sequence values. |
void |
visitStringValued(Sequence<? extends CharSequence> sequence,
P argument)
Visits a sequence that delivers any type of
value that implements the CharSequence interface,
including CharSequence it self. |
Methods inherited from interface dk.rode.thesis.visitor.SequenceVisitor |
---|
visitUnknown |
Method Detail |
---|
void visitDateValued(Sequence<Date> sequence, P argument)
sequence
that delivers Date
sequence values.
sequence
- The sequence to visit; never null.argument
- A visitor-specified argument, if any; nullability
determined by the visitor implementation.void visitIntegerValued(Sequence<Integer> sequence, P argument)
sequence
that delivers Integer
sequence values.
sequence
- The sequence to visit; never null.argument
- A visitor-specified argument, if any; nullability
determined by the visitor implementation.void visitLongValued(Sequence<Long> sequence, P argument)
sequence
that delivers Long
sequence values.
sequence
- The sequence to visit; never null.argument
- A visitor-specified argument, if any; nullability
determined by the visitor implementation.void visitStringValued(Sequence<? extends CharSequence> sequence, P argument)
sequence
that delivers any type of
value that implements the CharSequence
interface,
including CharSequence
it self.
sequence
- The sequence to visit; never null.argument
- A visitor-specified argument, if any; nullability
determined by the visitor implementation.
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |