下面列出了怎么用org.w3c.dom.UserDataHandler的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
public final Object setUserData(String key, Object data, UserDataHandler handler) {
if (key == null) {
throw new NullPointerException("key == null");
}
Map<String, UserData> map = document.getUserDataMap(this);
UserData previous = data == null
? map.remove(key)
: map.put(key, new UserData(data, handler));
return previous != null ? previous.value : null;
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* Returns a duplicate of a given node. You can consider this a
* generic "copy constructor" for nodes. The newly returned object should
* be completely independent of the source object's subtree, so changes
* in one after the clone has been made will not affect the other.
* <P>
* Note: since we never have any children deep is meaningless here,
* ParentNode overrides this behavior.
* @see ParentNode
*
* <p>
* Example: Cloning a Text node will copy both the node and the text it
* contains.
* <p>
* Example: Cloning something that has children -- Element or Attr, for
* example -- will _not_ clone those children unless a "deep clone"
* has been requested. A shallow clone of an Attr node will yield an
* empty Attr of the same name.
* <p>
* NOTE: Clones will always be read/write, even if the node being cloned
* is read-only, to permit applications using only the DOM API to obtain
* editable copies of locked portions of the tree.
*/
public Node cloneNode(boolean deep) {
if (needsSyncData()) {
synchronizeData();
}
NodeImpl newnode;
try {
newnode = (NodeImpl)clone();
}
catch (CloneNotSupportedException e) {
// if we get here we have an error in our program we may as well
// be vocal about it, so that people can take appropriate action.
throw new RuntimeException("**Internal Error**" + e);
}
// Need to break the association w/ original kids
newnode.ownerNode = ownerDocument();
newnode.isOwned(false);
// By default we make all clones readwrite,
// this is overriden in readonly subclasses
newnode.isReadOnly(false);
ownerDocument().callUserDataHandlers(this, newnode,
UserDataHandler.NODE_CLONED);
return newnode;
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* Returns a duplicate of a given node. You can consider this a
* generic "copy constructor" for nodes. The newly returned object should
* be completely independent of the source object's subtree, so changes
* in one after the clone has been made will not affect the other.
* <P>
* Note: since we never have any children deep is meaningless here,
* ParentNode overrides this behavior.
* @see ParentNode
*
* <p>
* Example: Cloning a Text node will copy both the node and the text it
* contains.
* <p>
* Example: Cloning something that has children -- Element or Attr, for
* example -- will _not_ clone those children unless a "deep clone"
* has been requested. A shallow clone of an Attr node will yield an
* empty Attr of the same name.
* <p>
* NOTE: Clones will always be read/write, even if the node being cloned
* is read-only, to permit applications using only the DOM API to obtain
* editable copies of locked portions of the tree.
*/
public Node cloneNode(boolean deep) {
if (needsSyncData()) {
synchronizeData();
}
NodeImpl newnode;
try {
newnode = (NodeImpl)clone();
}
catch (CloneNotSupportedException e) {
// if we get here we have an error in our program we may as well
// be vocal about it, so that people can take appropriate action.
throw new RuntimeException("**Internal Error**" + e);
}
// Need to break the association w/ original kids
newnode.ownerNode = ownerDocument();
newnode.isOwned(false);
// By default we make all clones readwrite,
// this is overriden in readonly subclasses
newnode.isReadOnly(false);
ownerDocument().callUserDataHandlers(this, newnode,
UserDataHandler.NODE_CLONED);
return newnode;
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* {@inheritDoc}
*/
@Override
public Object setUserData(final String key, final Object data, final UserDataHandler handler) {
if (userData_ == null) {
userData_ = new HashMap<>();
}
return userData_.put(key, data);
}
/**
* {@inheritDoc}
*/
@Override
public Object setUserData(final String key, final Object data, final UserDataHandler handler) {
if (userData_ == null) {
userData_ = new HashMap<>();
}
return userData_.put(key, data);
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
/**
* Returns a duplicate of a given node. You can consider this a
* generic "copy constructor" for nodes. The newly returned object should
* be completely independent of the source object's subtree, so changes
* in one after the clone has been made will not affect the other.
* <P>
* Note: since we never have any children deep is meaningless here,
* ParentNode overrides this behavior.
* @see ParentNode
*
* <p>
* Example: Cloning a Text node will copy both the node and the text it
* contains.
* <p>
* Example: Cloning something that has children -- Element or Attr, for
* example -- will _not_ clone those children unless a "deep clone"
* has been requested. A shallow clone of an Attr node will yield an
* empty Attr of the same name.
* <p>
* NOTE: Clones will always be read/write, even if the node being cloned
* is read-only, to permit applications using only the DOM API to obtain
* editable copies of locked portions of the tree.
*/
public Node cloneNode(boolean deep) {
if (needsSyncData()) {
synchronizeData();
}
NodeImpl newnode;
try {
newnode = (NodeImpl)clone();
}
catch (CloneNotSupportedException e) {
// if we get here we have an error in our program we may as well
// be vocal about it, so that people can take appropriate action.
throw new RuntimeException("**Internal Error**" + e);
}
// Need to break the association w/ original kids
newnode.ownerNode = ownerDocument();
newnode.isOwned(false);
// By default we make all clones readwrite,
// this is overriden in readonly subclasses
newnode.isReadOnly(false);
ownerDocument().callUserDataHandlers(this, newnode,
UserDataHandler.NODE_CLONED);
return newnode;
}
/**
* This DOM Level 3 method is not supported for {@code IIOMetadataNode}
* and will throw a {@code DOMException}.
* @throws DOMException - always.
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
@Override
public Object setUserData(final String key, final Object data, final UserDataHandler handler) {
throw new DOMException(DOMException.INVALID_ACCESS_ERR, SVGDocument.ACTION_NOT_IMPLEMENTED);
}
UserDataRecord(Object data, UserDataHandler handler) {
fData = data;
fHandler = handler;
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return null; //PENDING
}
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
UserDataRecord(Object data, UserDataHandler handler) {
fData = data;
fHandler = handler;
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return null; //PENDING
}
@Override
public Object setUserData(String key, Object data, UserDataHandler handler) {
return null;
}
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return null; //PENDING
}