2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
package org.apache.xerces.dom.events;
20
import org.w3c.dom.Node;
21
import org.w3c.dom.events.MutationEvent;
24
* An implementation of the DOM Level 2 <code>MutationEvent</code> interface.
28
* @version $Id: MutationEventImpl.java,v 1.2 2009/12/10 03:18:08 matthewoliver Exp $
30
public class MutationEventImpl
32
implements MutationEvent {
34
Node relatedNode = null;
35
String prevValue = null;
36
String newValue = null;
37
String attrName = null;
39
// REVISIT: The DOM Level 2 PR has a bug: the init method should let this
40
// attribute be specified. Since it doesn't we have to give write access.
41
public short attrChange;
43
// NON-DOM CONSTANTS: Storage efficiency, avoid risk of typos.
44
public static final String DOM_SUBTREE_MODIFIED = "DOMSubtreeModified";
45
public static final String DOM_NODE_INSERTED = "DOMNodeInserted";
46
public static final String DOM_NODE_REMOVED = "DOMNodeRemoved";
47
public static final String DOM_NODE_REMOVED_FROM_DOCUMENT = "DOMNodeRemovedFromDocument";
48
public static final String DOM_NODE_INSERTED_INTO_DOCUMENT = "DOMNodeInsertedIntoDocument";
49
public static final String DOM_ATTR_MODIFIED = "DOMAttrModified";
50
public static final String DOM_CHARACTER_DATA_MODIFIED = "DOMCharacterDataModified";
53
* @return the name of the Attr which
54
* changed, for DOMAttrModified events.
55
* Undefined for others.
57
public String getAttrName() {
62
* <code>attrChange</code> indicates the type of change which triggered
63
* the DOMAttrModified event. The values can be <code>MODIFICATION</code>
64
* , <code>ADDITION</code>, or <code>REMOVAL</code>.
66
public short getAttrChange() {
71
* @return the new string value of the Attr for DOMAttrModified events, or
72
* of the CharacterData node for DOMCharDataModifed events.
73
* Undefined for others.
75
public String getNewValue() {
80
* @return the previous string value of the Attr for DOMAttrModified events, or
81
* of the CharacterData node for DOMCharDataModifed events.
82
* Undefined for others.
84
public String getPrevValue() {
89
* @return a Node related to this event, other than the target that the
90
* node was dispatched to. For DOMNodeRemoved, it is the node which
92
* No other uses are currently defined.
94
public Node getRelatedNode() {
99
* Initialize a mutation event, or overwrite the event's current
100
* settings with new values of the parameters.
102
public void initMutationEvent(String typeArg, boolean canBubbleArg,
103
boolean cancelableArg, Node relatedNodeArg, String prevValueArg,
104
String newValueArg, String attrNameArg, short attrChangeArg) {
105
relatedNode = relatedNodeArg;
106
prevValue = prevValueArg;
107
newValue = newValueArg;
108
attrName = attrNameArg;
109
attrChange = attrChangeArg;
110
super.initEvent(typeArg, canBubbleArg, cancelableArg);