You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



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 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.