001 /*
002 * Copyright (c) 2004 World Wide Web Consortium,
003 *
004 * (Massachusetts Institute of Technology, European Research Consortium for
005 * Informatics and Mathematics, Keio University). All Rights Reserved. This
006 * work is distributed under the W3C(r) Software License [1] in the hope that
007 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
008 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
009 *
010 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
011 */
012
013 package org.w3c.dom;
014
015 /**
016 * When associating an object to a key on a node using
017 * <code>Node.setUserData()</code> the application can provide a handler
018 * that gets called when the node the object is associated to is being
019 * cloned, imported, or renamed. This can be used by the application to
020 * implement various behaviors regarding the data it associates to the DOM
021 * nodes. This interface defines that handler.
022 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.
023 * @since DOM Level 3
024 */
025 public interface UserDataHandler {
026 // OperationType
027 /**
028 * The node is cloned, using <code>Node.cloneNode()</code>.
029 */
030 public static final short NODE_CLONED = 1;
031 /**
032 * The node is imported, using <code>Document.importNode()</code>.
033 */
034 public static final short NODE_IMPORTED = 2;
035 /**
036 * The node is deleted.
037 * <p ><b>Note:</b> This may not be supported or may not be reliable in
038 * certain environments, such as Java, where the implementation has no
039 * real control over when objects are actually deleted.
040 */
041 public static final short NODE_DELETED = 3;
042 /**
043 * The node is renamed, using <code>Document.renameNode()</code>.
044 */
045 public static final short NODE_RENAMED = 4;
046 /**
047 * The node is adopted, using <code>Document.adoptNode()</code>.
048 */
049 public static final short NODE_ADOPTED = 5;
050
051 /**
052 * This method is called whenever the node for which this handler is
053 * registered is imported or cloned.
054 * <br> DOM applications must not raise exceptions in a
055 * <code>UserDataHandler</code>. The effect of throwing exceptions from
056 * the handler is DOM implementation dependent.
057 * @param operation Specifies the type of operation that is being
058 * performed on the node.
059 * @param key Specifies the key for which this handler is being called.
060 * @param data Specifies the data for which this handler is being called.
061 * @param src Specifies the node being cloned, adopted, imported, or
062 * renamed. This is <code>null</code> when the node is being deleted.
063 * @param dst Specifies the node newly created if any, or
064 * <code>null</code>.
065 */
066 public void handle(short operation,
067 String key,
068 Object data,
069 Node src,
070 Node dst);
071
072 }