KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > events > DOMMutationEvent


1 /*
2
3    Copyright 2000,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom.events;
19
20 import org.w3c.dom.Node JavaDoc;
21 import org.w3c.dom.events.MutationEvent JavaDoc;
22
23 /**
24  * The MutationEvent class provides specific contextual information
25  * associated with Mutation events.
26  *
27  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
28  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
29  */

30 public class DOMMutationEvent extends AbstractEvent implements MutationEvent JavaDoc {
31
32     private Node JavaDoc relatedNode;
33     private String JavaDoc prevValue;
34     private String JavaDoc newValue;
35     private String JavaDoc attrName;
36     private short attrChange;
37
38     /**
39      * DOM: <code>relatedNode</code> is used to identify a secondary
40      * node related to a mutation event. For example, if a mutation
41      * event is dispatched to a node indicating that its parent has
42      * changed, the <code>relatedNode</code> is the changed parent.
43      * If an event is instead dispatch to a subtree indicating a node
44      * was changed within it, the <code>relatedNode</code> is the
45      * changed node.
46      */

47     public Node JavaDoc getRelatedNode() {
48     return relatedNode;
49     }
50
51     /**
52      * DOM: <code>prevValue</code> indicates the previous value of the
53      * <code>Attr</code> node in DOMAttrModified events, and of the
54      * <code>CharacterData</code> node in DOMCharDataModified events.
55      */

56     public String JavaDoc getPrevValue() {
57     return prevValue;
58     }
59
60     /**
61      * DOM: <code>newValue</code> indicates the new value of the
62      * <code>Attr</code> node in DOMAttrModified events, and of the
63      * <code>CharacterData</code> node in DOMCharDataModified events.
64      */

65     public String JavaDoc getNewValue() {
66     return newValue;
67     }
68
69     /**
70      * DOM: <code>attrName</code> indicates the name of the changed
71      * <code>Attr</code> node in a DOMAttrModified event.
72      */

73     public String JavaDoc getAttrName() {
74     return attrName;
75     }
76
77     /**
78      * Implements {@link org.w3c.dom.events.MutationEvent#getAttrChange()}.
79      */

80     public short getAttrChange() {
81         return attrChange;
82     }
83
84     /**
85      * DOM: The <code>initMutationEvent</code> method is used to
86      * initialize the value of a <code>MutationEvent</code> created
87      * through the <code>DocumentEvent</code> interface. This method
88      * may only be called before the <code>MutationEvent</code> has
89      * been dispatched via the <code>dispatchEvent</code> method,
90      * though it may be called multiple times during that phase if
91      * necessary. If called multiple times, the final invocation
92      * takes precedence.
93      *
94      * @param typeArg Specifies the event type.
95      * @param canBubbleArg Specifies whether or not the event can bubble.
96      * @param cancelableArg Specifies whether or not the event's default
97      * action can be prevented.
98      * @param relatedNodeArg Specifies the <code>Event</code>'s related Node
99      * @param prevValueArg Specifies the <code>Event</code>'s
100      * <code>prevValue</code> property
101      * @param newValueArg Specifies the <code>Event</code>'s
102      * <code>newValue</code> property
103      * @param attrNameArg Specifies the <code>Event</code>'s
104      * <code>attrName</code> property
105      */

106     public void initMutationEvent(String JavaDoc typeArg,
107                   boolean canBubbleArg,
108                   boolean cancelableArg,
109                   Node JavaDoc relatedNodeArg,
110                   String JavaDoc prevValueArg,
111                   String JavaDoc newValueArg,
112                   String JavaDoc attrNameArg,
113                                   short attrChangeArg) {
114     initEvent(typeArg, canBubbleArg, cancelableArg);
115     this.relatedNode = relatedNodeArg;
116     this.prevValue = prevValueArg;
117     this.newValue = newValueArg;
118     this.attrName = attrNameArg;
119         this.attrChange = attrChangeArg;
120     }
121 }
122
Popular Tags