001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.dom.events;
019:
020: import org.w3c.dom.Node;
021: import org.w3c.dom.events.MutationEvent;
022:
023: /**
024: * An implementation of the DOM Level 2 <code>MutationEvent</code> interface.
025: *
026: * @xerces.internal
027: *
028: * @version $Id: MutationEventImpl.java 533531 2007-04-29 17:24:58Z mrglavas $
029: */
030: public class MutationEventImpl extends EventImpl implements
031: MutationEvent {
032:
033: Node relatedNode = null;
034: String prevValue = null;
035: String newValue = null;
036: String attrName = null;
037:
038: // REVISIT: The DOM Level 2 PR has a bug: the init method should let this
039: // attribute be specified. Since it doesn't we have to give write access.
040: public short attrChange;
041:
042: // NON-DOM CONSTANTS: Storage efficiency, avoid risk of typos.
043: public static final String DOM_SUBTREE_MODIFIED = "DOMSubtreeModified";
044: public static final String DOM_NODE_INSERTED = "DOMNodeInserted";
045: public static final String DOM_NODE_REMOVED = "DOMNodeRemoved";
046: public static final String DOM_NODE_REMOVED_FROM_DOCUMENT = "DOMNodeRemovedFromDocument";
047: public static final String DOM_NODE_INSERTED_INTO_DOCUMENT = "DOMNodeInsertedIntoDocument";
048: public static final String DOM_ATTR_MODIFIED = "DOMAttrModified";
049: public static final String DOM_CHARACTER_DATA_MODIFIED = "DOMCharacterDataModified";
050:
051: /**
052: * @return the name of the Attr which
053: * changed, for DOMAttrModified events.
054: * Undefined for others.
055: */
056: public String getAttrName() {
057: return attrName;
058: }
059:
060: /**
061: * <code>attrChange</code> indicates the type of change which triggered
062: * the DOMAttrModified event. The values can be <code>MODIFICATION</code>
063: * , <code>ADDITION</code>, or <code>REMOVAL</code>.
064: */
065: public short getAttrChange() {
066: return attrChange;
067: }
068:
069: /**
070: * @return the new string value of the Attr for DOMAttrModified events, or
071: * of the CharacterData node for DOMCharDataModifed events.
072: * Undefined for others.
073: */
074: public String getNewValue() {
075: return newValue;
076: }
077:
078: /**
079: * @return the previous string value of the Attr for DOMAttrModified events, or
080: * of the CharacterData node for DOMCharDataModifed events.
081: * Undefined for others.
082: */
083: public String getPrevValue() {
084: return prevValue;
085: }
086:
087: /**
088: * @return a Node related to this event, other than the target that the
089: * node was dispatched to. For DOMNodeRemoved, it is the node which
090: * was removed.
091: * No other uses are currently defined.
092: */
093: public Node getRelatedNode() {
094: return relatedNode;
095: }
096:
097: /**
098: * Initialize a mutation event, or overwrite the event's current
099: * settings with new values of the parameters.
100: */
101: public void initMutationEvent(String typeArg, boolean canBubbleArg,
102: boolean cancelableArg, Node relatedNodeArg,
103: String prevValueArg, String newValueArg,
104: 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: }
|