1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1.ber;
18
19
20 import java.util.ArrayList;
21
22
23 /***
24 * Tuple tree node visitor interface. Note that this is a more specific
25 * variant of the extrinsic visitor pattern. It has the following advantages
26 * over the standard visitor pattern:
27 * <ul>
28 * <li>Visitor takes responsibility that a visitor can visit a node</li>
29 * <li>Each visitor knows which types of concrete classes it can visit</li>
30 * <li>New visitors can be created without changing the node class</li>
31 * <li>New node classes can be added without having to change old visitors</li>
32 * <li>Visitation order can be controled in every respect:</li>
33 * <ul>
34 * <li>Visitation rejection with canVisit() and/or getOrder()</li>
35 * <li>Recursive visitation ordering with isPrefix()</li>
36 * <li>Child visitation ordering with getOrder()</li>
37 * </ul>
38 * </ul>
39 *
40 * @see TupleNode#accept(TupleNodeVisitor)
41 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
42 * @version $Rev: 157644 $
43 */
44 public interface TupleNodeVisitor
45 {
46 /***
47 * Visits a tree of tuple nodes using a specific visitation order.
48 *
49 * @param node the node to visit
50 */
51 void visit( TupleNode node ) ;
52
53 /***
54 * Checks to see if a node can be visited.
55 *
56 * @param node the node to be visited
57 * @return whether or node the node should be visited
58 */
59 boolean canVisit( TupleNode node ) ;
60
61 /***
62 * Determines whether the visitation order is prefix or postfix.
63 *
64 * @return true if the visitation is in prefix order, false otherwise.
65 */
66 boolean isPrefix() ;
67
68 /***
69 * Get the array of children to visit sequentially to determine the order of
70 * child visitations. Some children may not be returned at all if
71 * canVisit() returns false on them.
72 *
73 * @param node the parent branch node
74 * @param children the child node array
75 * @return the new reordered array of children
76 */
77 ArrayList getOrder( TupleNode node, ArrayList children ) ;
78
79 /***
80 * Sets the monitoring which recieves callbacks of notable events from
81 * this visitor.
82 *
83 * @param monitor the monitor instance for the visitor
84 */
85 void setMonitor( VisitorMonitor monitor );
86 }