use of org.w3c.dom.UserDataHandler in project webtools.sourceediting by eclipse.
the class NodeImpl method notifyUserDataHandlers.
/**
* Notifies the UserDataHandlers of the node.
*
* @param operation
* @param destination
*/
protected void notifyUserDataHandlers(short operation, Node destination) {
if (operation != UserDataHandler.NODE_ADOPTED & operation != UserDataHandler.NODE_CLONED & operation != UserDataHandler.NODE_DELETED & operation != UserDataHandler.NODE_IMPORTED & operation != UserDataHandler.NODE_RENAMED)
return;
Map userDataTable = UserData.getInstance().getUserDataTable(this);
if (userDataTable != null) {
Iterator entries = userDataTable.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
// should always be a string
String key = entry.getKey().toString();
UserDataAndHandler dataAndHandler = (UserDataAndHandler) entry.getValue();
if (dataAndHandler != null) {
UserDataHandler dataHandler = dataAndHandler.getHandler();
if (dataHandler != null) {
dataHandler.handle(operation, key, dataAndHandler.getData(), this, destination);
}
}
}
}
}
use of org.w3c.dom.UserDataHandler in project webtools.sourceediting by eclipse.
the class NodeImplTestCase method testNotifyUserDataHandler2.
/*
* Test for notifying the UserDataHandler when importing
*/
public void testNotifyUserDataHandler2() {
elementToImport = document.createElement("ElementToImport");
((NodeImpl) elementToImport).setUserData(KEY, VALUE, new UserDataHandler() {
public void handle(short operation, String key, Object data, Node src, Node dst) {
// parameters
if (operation == UserDataHandler.NODE_IMPORTED) {
assertEquals(VALUE, data);
assertEquals(KEY, key);
assertEquals(src, elementToImport);
assertEquals(dst, null);
if (DEBUG)
System.out.println("Operation: " + operation + " Key:" + key + " Object:" + data + " SourceNode:" + src.getLocalName() + " DestinationNode:" + dst);
}
}
});
document.importNode(elementToImport, true);
}
use of org.w3c.dom.UserDataHandler in project webtools.sourceediting by eclipse.
the class NodeImplTestCase method testNotifyUserDataHandler1.
/*
* Test for notifying the UserDataHandler when cloning an attribute
*/
public void testNotifyUserDataHandler1() {
attribute.setUserData(KEY, VALUE, new UserDataHandler() {
public void handle(short operation, String key, Object data, Node src, Node dst) {
assertEquals(UserDataHandler.NODE_CLONED, operation);
assertEquals(VALUE, data);
assertEquals(KEY, key);
assertEquals(src, attribute);
if (DEBUG)
System.out.println("Operation: " + operation + " Key:" + key + " Object:" + data + " SourceNode:" + src.getLocalName() + " DestinationNode:" + dst.getLocalName());
}
});
// event occurs before the destinationNode returns....
destinationNode = (AttrImpl) attribute.cloneNode(true);
}
Aggregations