1 /*
2  * Copyright (c) 2004 World Wide Web Consortium,
3  *
4  * (Massachusetts Institute of Technology, European Research Consortium for
5  * Informatics and Mathematics, Keio University). All Rights Reserved. This
6  * work is distributed under the W3C(r) Software License [1] in the hope that
7  * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
8  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  *
10  * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11  */
12 
13 package org.w3c.dom;
14 
15 /**
16  * When associating an object to a key on a node using
17  * <code>Node.setUserData()</code> the application can provide a handler
18  * that gets called when the node the object is associated to is being
19  * cloned, imported, or renamed. This can be used by the application to
20  * implement various behaviors regarding the data it associates to the DOM
21  * nodes. This interface defines that handler.
22  * <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>.
23  * @since DOM Level 3
24  */
25 public interface UserDataHandler {
26     // OperationType
27     /**
28      * The node is cloned, using <code>Node.cloneNode()</code>.
29      */
30     public static final short NODE_CLONED               = 1;
31     /**
32      * The node is imported, using <code>Document.importNode()</code>.
33      */
34     public static final short NODE_IMPORTED             = 2;
35     /**
36      * The node is deleted.
37      * <p ><b>Note:</b> This may not be supported or may not be reliable in
38      * certain environments, such as Java, where the implementation has no
39      * real control over when objects are actually deleted.
40      */
41     public static final short NODE_DELETED              = 3;
42     /**
43      * The node is renamed, using <code>Document.renameNode()</code>.
44      */
45     public static final short NODE_RENAMED              = 4;
46     /**
47      * The node is adopted, using <code>Document.adoptNode()</code>.
48      */
49     public static final short NODE_ADOPTED              = 5;
50 
51     /**
52      * This method is called whenever the node for which this handler is
53      * registered is imported or cloned.
54      * <br> DOM applications must not raise exceptions in a
55      * <code>UserDataHandler</code>. The effect of throwing exceptions from
56      * the handler is DOM implementation dependent.
57      * @param operation Specifies the type of operation that is being
58      *   performed on the node.
59      * @param key Specifies the key for which this handler is being called.
60      * @param data Specifies the data for which this handler is being called.
61      * @param src Specifies the node being cloned, adopted, imported, or
62      *   renamed. This is <code>null</code> when the node is being deleted.
63      * @param dst Specifies the node newly created if any, or
64      *   <code>null</code>.
65      */
handle(short operation, String key, Object data, Node src, Node dst)66     public void handle(short operation,
67                        String key,
68                        Object data,
69                        Node src,
70                        Node dst);
71 
72 }
73