~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/dom/events/MutationEventImpl.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
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.xerces.dom.events;
 
19
 
 
20
import org.w3c.dom.Node;
 
21
import org.w3c.dom.events.MutationEvent;
 
22
 
 
23
/**
 
24
 * An implementation of the DOM Level 2 <code>MutationEvent</code> interface.
 
25
 * 
 
26
 * @xerces.internal 
 
27
 * 
 
28
 * @version $Id: MutationEventImpl.java,v 1.2 2009/12/10 03:18:08 matthewoliver Exp $
 
29
 */
 
30
public class MutationEventImpl 
 
31
    extends EventImpl 
 
32
    implements MutationEvent {
 
33
    
 
34
    Node relatedNode = null;
 
35
    String prevValue = null;
 
36
    String newValue = null;
 
37
    String attrName = null;
 
38
 
 
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;
 
42
 
 
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";
 
51
 
 
52
    /** 
 
53
     * @return the name of the Attr which
 
54
     * changed, for DOMAttrModified events. 
 
55
     * Undefined for others.
 
56
     */
 
57
    public String getAttrName() {
 
58
        return attrName;
 
59
    }
 
60
 
 
61
    /**
 
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>. 
 
65
     */
 
66
    public short getAttrChange() {
 
67
        return attrChange;
 
68
    }
 
69
 
 
70
    /** 
 
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.
 
74
     */
 
75
    public String getNewValue() {
 
76
        return newValue;
 
77
    }
 
78
 
 
79
    /** 
 
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.
 
83
     */
 
84
    public String getPrevValue() {
 
85
        return prevValue;
 
86
    }
 
87
 
 
88
    /** 
 
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
 
91
     * was removed. 
 
92
     * No other uses are currently defined.
 
93
     */
 
94
    public Node getRelatedNode() {
 
95
        return relatedNode;
 
96
    }
 
97
 
 
98
    /** 
 
99
     * Initialize a mutation event, or overwrite the event's current
 
100
     * settings with new values of the parameters. 
 
101
     */
 
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);
 
111
    }
 
112
}