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. package org.w3c.dom;
  13. /**
  14. * When associating an object to a key on a node using
  15. * <code>Node.setUserData()</code> the application can provide a handler
  16. * that gets called when the node the object is associated to is being
  17. * cloned, imported, or renamed. This can be used by the application to
  18. * implement various behaviors regarding the data it associates to the DOM
  19. * nodes. This interface defines that handler.
  20. * <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>.
  21. * @since DOM Level 3
  22. */
  23. public interface UserDataHandler {
  24. // OperationType
  25. /**
  26. * The node is cloned, using <code>Node.cloneNode()</code>.
  27. */
  28. public static final short NODE_CLONED = 1;
  29. /**
  30. * The node is imported, using <code>Document.importNode()</code>.
  31. */
  32. public static final short NODE_IMPORTED = 2;
  33. /**
  34. * The node is deleted.
  35. * <p ><b>Note:</b> This may not be supported or may not be reliable in
  36. * certain environments, such as Java, where the implementation has no
  37. * real control over when objects are actually deleted.
  38. */
  39. public static final short NODE_DELETED = 3;
  40. /**
  41. * The node is renamed, using <code>Document.renameNode()</code>.
  42. */
  43. public static final short NODE_RENAMED = 4;
  44. /**
  45. * The node is adopted, using <code>Document.adoptNode()</code>.
  46. */
  47. public static final short NODE_ADOPTED = 5;
  48. /**
  49. * This method is called whenever the node for which this handler is
  50. * registered is imported or cloned.
  51. * <br> DOM applications must not raise exceptions in a
  52. * <code>UserDataHandler</code>. The effect of throwing exceptions from
  53. * the handler is DOM implementation dependent.
  54. * @param operation Specifies the type of operation that is being
  55. * performed on the node.
  56. * @param key Specifies the key for which this handler is being called.
  57. * @param data Specifies the data for which this handler is being called.
  58. * @param src Specifies the node being cloned, adopted, imported, or
  59. * renamed. This is <code>null</code> when the node is being deleted.
  60. * @param dst Specifies the node newly created if any, or
  61. * <code>null</code>.
  62. */
  63. public void handle(short operation,
  64. String key,
  65. Object data,
  66. Node src,
  67. Node dst);
  68. }