|
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.visitor.SimpleScanner
@Participant(value="ObjectStructure") public class SimpleScanner
A simple scanner can traverse both
type
and value
visitable sequences based on a traversal strategy
that can be supplied at construction
time, or changed runtime using the setCompositeStrategy(CompositeStrategy)
method.
Field Summary | |
---|---|
private CompositeStrategy |
strategy
The composite traversal strategy to use. |
Constructor Summary | |
---|---|
SimpleScanner()
No-arg constructor. |
|
SimpleScanner(CompositeStrategy strategy)
Constructor. |
Method Summary | ||
---|---|---|
CompositeStrategy |
getCompositeStrategy()
Return the currently used strategy
by this scanner to traverse sequence
structures. |
|
|
scan(TypeVisitableSequence<?> sequence,
SequenceTypeVisitor<P> visitor,
P argument)
Performs the traversal of the sequence structure starting with sequence using the type
visitor supplied as visitor . |
|
|
scan(ValueVisitableSequence<?> sequence,
SequenceValueVisitor<P> visitor,
P argument)
Performs the traversal of the sequence structure starting with sequence using the value
visitor supplied as visitor . |
|
void |
setCompositeStrategy(CompositeStrategy strategy)
Sets the strategy to use by this
scanner to traverse sequence structures to
strategy |
|
String |
toString()
Returns the string representation of this simple scanner. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private CompositeStrategy strategy
Null means default strategy per composite.
Constructor Detail |
---|
public SimpleScanner()
The default strategy is used per composite.
public SimpleScanner(CompositeStrategy strategy)
strategy
- The composite strategy to use for the traversal;
can be null, i.e. default.Method Detail |
---|
public CompositeStrategy getCompositeStrategy()
strategy
by this scanner to traverse sequence
structures.
setCompositeStrategy(CompositeStrategy)
,
CompositeSequence.getCompositeStrategy()
public <P> void scan(TypeVisitableSequence<?> sequence, SequenceTypeVisitor<P> visitor, P argument)
SequenceTypeScanner
sequence
using the type
visitor supplied as visitor
. If sequence
is non-composite, it will be the only sequence visited.
For each type
visitable sequence
found in the sequence structure, the
TypeVisitableSequence.accept(SequenceTypeVisitor, Object)
visitation method is invoked.
scan
in interface SequenceTypeScanner
P
- The type of the additional parameter to required by
visitor
. Use Void
for visitors that
do not need an additional parameter.sequence
- The starting sequence ("root"); cannot be null.visitor
- The type visitor to use; cannot be null.argument
- A visitor
specified argument, if any;
nullability determined by visitor
.
NullPointerException
- If sequence
or visitor
are null.public <P> void scan(ValueVisitableSequence<?> sequence, SequenceValueVisitor<P> visitor, P argument)
SequenceValueScanner
sequence
using the value
visitor supplied as visitor
. If sequence
is non-composite, it will be the only sequence visited.
For each value
visitable sequence
found in the sequence structure, the
ValueVisitableSequence.accept(SequenceValueVisitor, Object)
visitation method is invoked.
scan
in interface SequenceValueScanner
P
- The type of the additional parameter to required by
visitor
. Use Void
for visitors that
do not need an additional parameter.sequence
- The starting sequence ("root"); cannot be null.visitor
- The value visitor to use; cannot be null.argument
- A visitor
specified argument, if any;
nullability determined by visitor
.
NullPointerException
- If sequence
or visitor
are null.public void setCompositeStrategy(CompositeStrategy strategy)
strategy
to use by this
scanner to traverse sequence
structures to
strategy
strategy
- The strategy to use; can be null, which means
default strategy per composite.getCompositeStrategy()
,
CompositeSequence.getCompositeStrategy()
public String toString()
toString
in class Object
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |