blob: 6779c31dc3c4b4db6178fc1410c2c7c5ee8cfafa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package org.eclipse.jst.jsf.common.runtime.internal.model.component;
/**
* Implemented by visitors
*
* @author cbateman
*
*/
public abstract class AbstractVisitor
{
/**
* A policy to control visitation
*/
protected final VisitationPolicy _policy;
/**
* @param policy
*/
protected AbstractVisitor(final VisitationPolicy policy)
{
super();
_policy = policy;
}
/**
* @param object
*/
public abstract void visit(Object object);
/**
* @return the visitation policy
*/
public VisitationPolicy getPolicy()
{
return _policy;
}
/**
* A policy that allows a visitor to configure how it will visit a tree.
*
*/
public static final class VisitationPolicy
{
/**
* indicates pre-order, parent first traversal (root visited first)
*/
public static final int VISIT_PARENT_FIRST = 0; // pre-order
// tree
// visit
/**
* indicates post-order, children first traveral (root visited last)
*/
public static final int VISIT_CHILDREN_FIRST = 1; // post-order
// tree
// visit
/**
* A default parent first policy
*/
public final static VisitationPolicy ParentFirstPolicy = new VisitationPolicy(
VISIT_PARENT_FIRST);
/**
* A default children first policy
*/
public final static VisitationPolicy ChildrenFirstPolicy = new VisitationPolicy(
VISIT_CHILDREN_FIRST);
private final int _ordering;
/**
* @param ordering
*/
public VisitationPolicy(final int ordering)
{
_ordering = ordering;
}
/**
* @return the ordering
*/
public final int getOrdering()
{
return _ordering;
}
}
}
|