1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements.  See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22package com.sun.org.apache.xerces.internal.dom.events;
23
24import org.w3c.dom.Node;
25import org.w3c.dom.events.MutationEvent;
26
27/**
28 * @xerces.internal
29 *
30 */
31
32public class MutationEventImpl
33extends com.sun.org.apache.xerces.internal.dom.events.EventImpl
34implements MutationEvent
35{
36    Node relatedNode=null;
37    String prevValue=null,newValue=null,attrName=null;
38    // REVISIT: The DOM Level 2 PR has a bug: the init method should let this
39    // attribute be specified. Since it doesn't we have to give write access.
40    public short attrChange;
41
42    // NON-DOM CONSTANTS: Storage efficiency, avoid risk of typos.
43    public static final String DOM_SUBTREE_MODIFIED = "DOMSubtreeModified";
44    public static final String DOM_NODE_INSERTED = "DOMNodeInserted";
45    public static final String DOM_NODE_REMOVED = "DOMNodeRemoved";
46    public static final String DOM_NODE_REMOVED_FROM_DOCUMENT = "DOMNodeRemovedFromDocument";
47    public static final String DOM_NODE_INSERTED_INTO_DOCUMENT = "DOMNodeInsertedIntoDocument";
48    public static final String DOM_ATTR_MODIFIED = "DOMAttrModified";
49    public static final String DOM_CHARACTER_DATA_MODIFIED = "DOMCharacterDataModified";
50
51    /** @return the name of the Attr which
52        changed, for DOMAttrModified events.
53        Undefined for others.
54        */
55    public String getAttrName()
56    {
57        return attrName;
58    }
59
60    /**
61     *  <code>attrChange</code> indicates the type of change which triggered
62     * the DOMAttrModified event. The values can be <code>MODIFICATION</code>
63     * , <code>ADDITION</code>, or <code>REMOVAL</code>.
64     */
65    public short getAttrChange()
66    {
67        return attrChange;
68    }
69
70    /** @return the new string value of the Attr for DOMAttrModified events, or
71        of the CharacterData node for DOMCharDataModifed events.
72        Undefined for others.
73        */
74    public String getNewValue()
75    {
76        return newValue;
77    }
78
79    /** @return the previous string value of the Attr for DOMAttrModified events, or
80        of the CharacterData node for DOMCharDataModifed events.
81        Undefined for others.
82        */
83    public String getPrevValue()
84    {
85        return prevValue;
86    }
87
88    /** @return a Node related to this event, other than the target that the
89        node was dispatched to. For DOMNodeRemoved, it is the node which
90        was removed.
91        No other uses are currently defined.
92        */
93    public Node getRelatedNode()
94    {
95        return relatedNode;
96    }
97
98    /** Initialize a mutation event, or overwrite the event's current
99        settings with new values of the parameters.
100        */
101    public void initMutationEvent(String typeArg, boolean canBubbleArg,
102        boolean cancelableArg, Node relatedNodeArg, String prevValueArg,
103        String newValueArg, String attrNameArg, short attrChangeArg)
104    {
105        relatedNode=relatedNodeArg;
106        prevValue=prevValueArg;
107        newValue=newValueArg;
108        attrName=attrNameArg;
109        attrChange=attrChangeArg;
110        super.initEvent(typeArg,canBubbleArg,cancelableArg);
111    }
112
113}
114