Stay organized with collections
Save and categorize content based on your preferences.
UserDataHandler
public
interface
UserDataHandler
org.w3c.dom.UserDataHandler
|
When associating an object to a key on a node using
Node.setUserData()
the application can provide a handler
that gets called when the node the object is associated to is being
cloned, imported, or renamed. This can be used by the application to
implement various behaviors regarding the data it associates to the DOM
nodes. This interface defines that handler.
See also the Document Object Model (DOM) Level 3 Core Specification.
Summary
Constants |
short |
NODE_ADOPTED
The node is adopted, using Document.adoptNode() .
|
short |
NODE_CLONED
The node is cloned, using Node.cloneNode() .
|
short |
NODE_DELETED
The node is deleted.
|
short |
NODE_IMPORTED
The node is imported, using Document.importNode() .
|
short |
NODE_RENAMED
The node is renamed, using Document.renameNode() .
|
Public methods |
abstract
void
|
handle(short operation, String key, Object data, Node src, Node dst)
This method is called whenever the node for which this handler is
registered is imported or cloned.
|
Constants
NODE_ADOPTED
public static final short NODE_ADOPTED
The node is adopted, using Document.adoptNode()
.
Constant Value:
5
(0x00000005)
NODE_CLONED
public static final short NODE_CLONED
The node is cloned, using Node.cloneNode()
.
Constant Value:
1
(0x00000001)
NODE_DELETED
public static final short NODE_DELETED
The node is deleted.
Note: This may not be supported or may not be reliable in
certain environments, such as Java, where the implementation has no
real control over when objects are actually deleted.
Constant Value:
3
(0x00000003)
NODE_IMPORTED
public static final short NODE_IMPORTED
The node is imported, using Document.importNode()
.
Constant Value:
2
(0x00000002)
NODE_RENAMED
public static final short NODE_RENAMED
The node is renamed, using Document.renameNode()
.
Constant Value:
4
(0x00000004)
Public methods
handle
public abstract void handle (short operation,
String key,
Object data,
Node src,
Node dst)
This method is called whenever the node for which this handler is
registered is imported or cloned.
DOM applications must not raise exceptions in a
UserDataHandler
. The effect of throwing exceptions from
the handler is DOM implementation dependent.
Parameters |
operation |
short : Specifies the type of operation that is being
performed on the node. |
key |
String : Specifies the key for which this handler is being called. |
data |
Object : Specifies the data for which this handler is being called. |
src |
Node : Specifies the node being cloned, adopted, imported, or
renamed. This is null when the node is being deleted. |
dst |
Node : Specifies the node newly created if any, or
null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# UserDataHandler\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nUserDataHandler\n===============\n\n\n`\npublic\n\n\ninterface\nUserDataHandler\n`\n\n\n`\n\n\n`\n\n|-----------------------------|\n| org.w3c.dom.UserDataHandler |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nWhen associating an object to a key on a node using\n`Node.setUserData()` the application can provide a handler\nthat gets called when the node the object is associated to is being\ncloned, imported, or renamed. This can be used by the application to\nimplement various behaviors regarding the data it associates to the DOM\nnodes. This interface defines that handler.\n\nSee also the [Document Object Model (DOM) Level 3 Core Specification](http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407).\n\nSummary\n-------\n\n| ### Constants ||\n|---------|----------------------------------------------------------------------------------------------------------------------------|\n| `short` | [NODE_ADOPTED](/reference/org/w3c/dom/UserDataHandler#NODE_ADOPTED) The node is adopted, using `Document.adoptNode()`. |\n| `short` | [NODE_CLONED](/reference/org/w3c/dom/UserDataHandler#NODE_CLONED) The node is cloned, using `Node.cloneNode()`. |\n| `short` | [NODE_DELETED](/reference/org/w3c/dom/UserDataHandler#NODE_DELETED) The node is deleted. |\n| `short` | [NODE_IMPORTED](/reference/org/w3c/dom/UserDataHandler#NODE_IMPORTED) The node is imported, using `Document.importNode()`. |\n| `short` | [NODE_RENAMED](/reference/org/w3c/dom/UserDataHandler#NODE_RENAMED) The node is renamed, using `Document.renameNode()`. |\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[handle](/reference/org/w3c/dom/UserDataHandler#handle(short,%20java.lang.String,%20java.lang.Object,%20org.w3c.dom.Node,%20org.w3c.dom.Node))`(short operation, `[String](/reference/java/lang/String)` key, `[Object](/reference/java/lang/Object)` data, `[Node](/reference/org/w3c/dom/Node)` src, `[Node](/reference/org/w3c/dom/Node)` dst) ` This method is called whenever the node for which this handler is registered is imported or cloned. |\n\nConstants\n---------\n\n### NODE_ADOPTED\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final short NODE_ADOPTED\n```\n\nThe node is adopted, using `Document.adoptNode()`.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n5\n(0x00000005)\n\n\n### NODE_CLONED\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final short NODE_CLONED\n```\n\nThe node is cloned, using `Node.cloneNode()`.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n1\n(0x00000001)\n\n\n### NODE_DELETED\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final short NODE_DELETED\n```\n\nThe node is deleted.\n\n**Note:** This may not be supported or may not be reliable in\ncertain environments, such as Java, where the implementation has no\nreal control over when objects are actually deleted.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n3\n(0x00000003)\n\n\n### NODE_IMPORTED\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final short NODE_IMPORTED\n```\n\nThe node is imported, using `Document.importNode()`.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n2\n(0x00000002)\n\n\n### NODE_RENAMED\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final short NODE_RENAMED\n```\n\nThe node is renamed, using `Document.renameNode()`.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n4\n(0x00000004)\n\n\nPublic methods\n--------------\n\n### handle\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void handle (short operation, \n String key, \n Object data, \n Node src, \n Node dst)\n```\n\nThis method is called whenever the node for which this handler is\nregistered is imported or cloned.\n\nDOM applications must not raise exceptions in a\n`UserDataHandler`. The effect of throwing exceptions from\nthe handler is DOM implementation dependent.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `operation` | `short`: Specifies the type of operation that is being performed on the node. \u003cbr /\u003e |\n| `key` | `String`: Specifies the key for which this handler is being called. \u003cbr /\u003e |\n| `data` | `Object`: Specifies the data for which this handler is being called. \u003cbr /\u003e |\n| `src` | `Node`: Specifies the node being cloned, adopted, imported, or renamed. This is `null` when the node is being deleted. \u003cbr /\u003e |\n| `dst` | `Node`: Specifies the node newly created if any, or `null`. \u003cbr /\u003e |"]]