- 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 as Node.getAttributes(). If a node does not have
any attributes, a null object will be returned, instead
of an empty NamedNodeMap with zero elements, in
accordance with the spec.