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

dk.rode.thesis.visitor
Interface SequenceValueVisitor<P>

Type Parameters:
P - The type of the additional parameter to this visitor's methods. Use Void for visitors that do not need an additional parameter.
All Superinterfaces:
SequenceVisitor<P>
All Known Implementing Classes:
CountingVisitor, LoggingVisitor

@Participant(value="Visitor")
public interface SequenceValueVisitor<P>
extends SequenceVisitor<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, P) 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]).

Author:
Gunni Rode / rode.dk
See Also:
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

visitDateValued

void visitDateValued(Sequence<Date> sequence,
                     P argument)
Visits a sequence that delivers Date sequence values.

Parameters:
sequence - The sequence to visit; never null.
argument - A visitor-specified argument, if any; nullability determined by the visitor implementation.

visitIntegerValued

void visitIntegerValued(Sequence<Integer> sequence,
                        P argument)
Visits a sequence that delivers Integer sequence values.

Parameters:
sequence - The sequence to visit; never null.
argument - A visitor-specified argument, if any; nullability determined by the visitor implementation.

visitLongValued

void visitLongValued(Sequence<Long> sequence,
                     P argument)
Visits a sequence that delivers Long sequence values.

Parameters:
sequence - The sequence to visit; never null.
argument - A visitor-specified argument, if any; nullability determined by the visitor implementation.

visitStringValued

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.

Parameters:
sequence - The sequence to visit; never null.
argument - A visitor-specified argument, if any; nullability determined by the visitor implementation.

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.