Java DOM API
Module Owner - Ashutosh Kulkarni < ashuk@eng.sun.com>Original Document by - Akhil Arora
The Java DOM API is part of the Blackwood project. It is an implementation of the Java bindings specified in Document Object Model (DOM) Level 1 Specification. Only the core DOM interfaces are implemented.
- Why?
The primary purpose of the Java DOM API is to allow Java Applets and Pluglets to interact with and modify the document they are embedded into. An Applet, for example, need not even have a display area, it can do its work solely through DOM manipulations.
- How?
The Java DOM API is written as a very thin layer on top of the C++
coreDOM
API using JNI. Each Java object delegates all method calls to the corresponding C++coreDOM
object. - Using the API
The API is intended to be used by Java Applets, Java Pluglets and Java Applications that embed Gecko. Some important things to keep in mind when using the API are listed below.
- Thread safety
It is only safe to access and manipulate the DOM from within a method of the
DocumentLoadListener
interface, since these calls are made from the main layout thread. Trying to access or manipulate the DOM from any other thread is unsafe. We may be able to work around this limitation using nsISupports Proxies. - Null returns
API users need to check for
null
returns from methods such asNode.getAttributes()
. If a node does not have any attributes, anull
object will be returned, instead of an emptyNamedNodeMap
with zero elements, in accordance with the spec.
- Thread safety