KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > dom > NodeEventHandler


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.dom;
12
13 /**
14  * A node event handler is an internal mechanism for receiving
15  * notification of changes to nodes in an AST.
16  * <p>
17  * The default implementation serves as the default event handler
18  * that does nothing. Internal subclasses do all the real work.
19  * </p>
20  *
21  * @see AST#getEventHandler()
22  */

23 class NodeEventHandler {
24
25     /**
26      * Creates a node event handler.
27      */

28     NodeEventHandler() {
29         // default implementation: do nothing
30
}
31     
32     /**
33      * Reports that the given node is about to lose a child.
34      * The first half of an event pair. The default implementation does nothing.
35      *
36      * @param node the node about to be modified
37      * @param child the node about to be removed
38      * @param property the child or child list property descriptor
39      * @see #postRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
40      * @since 3.0
41      */

42     void preRemoveChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
43         // do nothing
44
// System.out.println("DEL1 " + property); //$NON-NLS-1$
45
}
46     
47     /**
48      * Reports that the given node has just lose a child.
49      * The second half of an event pair. The default implementation does nothing.
50      *
51      * @param node the node that was modified
52      * @param child the child that was removed; note that this node is unparented
53      * @param property the child or child list property descriptor
54      * @see #preRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
55      * @since 3.0
56      */

57     void postRemoveChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
58         // do nothing
59
// System.out.println("DEL2 " + property); //$NON-NLS-1$
60
}
61     
62     /**
63      * Reports that the given node is about to have a child replaced.
64      * The first half of an event pair.
65      * The default implementation does nothing.
66      *
67      * @param node the node about to be modified
68      * @param child the node about to be replaced
69      * @param newChild the replacement child; note that this node is unparented
70      * @param property the child or child list property descriptor
71      * @see #preReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
72      * @since 3.0
73      */

74     void preReplaceChildEvent(ASTNode node, ASTNode child, ASTNode newChild, StructuralPropertyDescriptor property) {
75         // do nothing
76
// System.out.println("REP1 " + property); //$NON-NLS-1$
77
}
78     
79     /**
80      * Reports that the given node has had its child replaced. The second half
81      * of an event pair. The default implementation does nothing.
82      *
83      * @param node the node that was modified
84      * @param child the node that was replaced; note that this node is unparented
85      * @param newChild the replacement child
86      * @param property the child or child list property descriptor
87      * @see #postReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
88      * @since 3.0
89      */

90     void postReplaceChildEvent(ASTNode node, ASTNode child, ASTNode newChild, StructuralPropertyDescriptor property) {
91         // do nothing
92
// System.out.println("REP2 " + property); //$NON-NLS-1$
93
}
94     
95     /**
96      * Reports that the given node is about to gain a child.
97      * The first half of an event pair. The default implementation does nothing.
98      *
99      * @param node the node that to be modified
100      * @param child the node that is to be added as a child; note that this
101      * node is unparented; in the case of a child list property, the exact
102      * location of insertion is not supplied (but is known on the
103      * corresponding <code>postAddChildEvent</code> to
104      * follow)
105      * @param property the child or child list property descriptor
106      * @see #postAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
107      * @since 3.0
108      */

109     void preAddChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
110         // do nothing
111
// System.out.println("ADD1 " + property); //$NON-NLS-1$
112
}
113     
114     /**
115      * Reports that the given node has just gained a child.
116      * The second half of an event pair. The default implementation does nothing.
117      *
118      * @param node the node that was modified
119      * @param child the node that was added as a child
120      * @param property the child or child list property descriptor
121      * @see #preAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
122      * @since 3.0
123      */

124     void postAddChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
125         // do nothing
126
// System.out.println("ADD2 " + property); //$NON-NLS-1$
127
}
128     
129     /**
130      * Reports that the given node is about to change the value of a
131      * non-child property. The first half of an event pair.
132      * The default implementation does nothing.
133      *
134      * @param node the node to be modified
135      * @param property the property descriptor
136      * @see #postValueChangeEvent(ASTNode, SimplePropertyDescriptor)
137      * @since 3.0
138      */

139     void preValueChangeEvent(ASTNode node, SimplePropertyDescriptor property) {
140         // do nothing
141
// System.out.println("MOD1 " + property); //$NON-NLS-1$
142
}
143
144     /**
145      * Reports that the given node has just changed the value of a
146      * non-child property. The second half of an event pair.
147      * The default implementation does nothing.
148      *
149      * @param node the node that was modified
150      * @param property the property descriptor
151      * @see #preValueChangeEvent(ASTNode, SimplePropertyDescriptor)
152      * @since 3.0
153      */

154     void postValueChangeEvent(ASTNode node, SimplePropertyDescriptor property) {
155         // do nothing
156
// System.out.println("MOD2 " + property); //$NON-NLS-1$
157
}
158     
159     /**
160      * Reports that the given node is about to be cloned.
161      * The first half of an event pair.
162      * The default implementation does nothing.
163      *
164      * @param node the node to be modified
165      * @see #postCloneNodeEvent(ASTNode, ASTNode)
166      * @since 3.0
167      */

168     void preCloneNodeEvent(ASTNode node) {
169         // do nothing
170
// System.out.println("CLONE1"); //$NON-NLS-1$
171
}
172
173     /**
174      * Reports that the given node has just been cloned.
175      * The second half of an event pair.
176      * The default implementation does nothing.
177      *
178      * @param node the node that was modified
179      * @param clone the clone of <code>node</code>
180      * @see #preCloneNodeEvent(ASTNode)
181      * @since 3.0
182      */

183     void postCloneNodeEvent(ASTNode node, ASTNode clone) {
184         // do nothing
185
// System.out.println("CLONE2"); //$NON-NLS-1$
186
}
187     
188 }
189
Popular Tags