mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +00:00
b8a239fb24
changed the way java dom registers itself
137 lines
3.6 KiB
Java
137 lines
3.6 KiB
Java
/*
|
|
The contents of this file are subject to the Mozilla Public
|
|
License Version 1.1 (the "License"); you may not use this file
|
|
except in compliance with the License. You may obtain a copy of
|
|
the License at http://www.mozilla.org/MPL/
|
|
|
|
Software distributed under the License is distributed on an "AS
|
|
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
implied. See the License for the specific language governing
|
|
rights and limitations under the License.
|
|
|
|
The Original Code is mozilla.org code.
|
|
|
|
The Initial Developer of the Original Code is Sun Microsystems,
|
|
Inc. Portions created by Sun are
|
|
Copyright (C) 1999 Sun Microsystems, Inc. All
|
|
Rights Reserved.
|
|
|
|
Contributor(s):
|
|
*/
|
|
|
|
package org.mozilla.dom;
|
|
|
|
import java.util.Vector;
|
|
import java.util.Enumeration;
|
|
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
|
|
public class DOMAccessorImpl implements DOMAccessor, DocumentLoadListener {
|
|
|
|
private static DOMAccessor instance = null;
|
|
private Vector documentLoadListeners = new Vector();
|
|
|
|
static {
|
|
System.loadLibrary("javadomjni");
|
|
}
|
|
|
|
private void DOMAccessorImpl() {}
|
|
|
|
private static native void register();
|
|
private static native void unregister();
|
|
private static native Element getElementByHandle(long p);
|
|
|
|
public static synchronized DOMAccessor getInstance() {
|
|
if (instance == null) {
|
|
instance = new DOMAccessorImpl();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
public synchronized void
|
|
addDocumentLoadListener(DocumentLoadListener listener) {
|
|
if (documentLoadListeners.size() == 0) {
|
|
register();
|
|
}
|
|
documentLoadListeners.addElement(listener);
|
|
}
|
|
|
|
public synchronized void
|
|
removeDocumentLoadListener(DocumentLoadListener listener) {
|
|
|
|
documentLoadListeners.removeElement(listener);
|
|
if (documentLoadListeners.size() == 0) {
|
|
unregister();
|
|
}
|
|
}
|
|
|
|
public synchronized void
|
|
startURLLoad(String url, String contentType, Document doc) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.startURLLoad(url, contentType, doc);
|
|
}
|
|
}
|
|
|
|
public synchronized void
|
|
endURLLoad(String url, int status, Document doc) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.endURLLoad(url, status, doc);
|
|
}
|
|
}
|
|
|
|
public synchronized void
|
|
progressURLLoad(String url, int progress, int progressMax,
|
|
Document doc) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.progressURLLoad(url, progress, progressMax, doc);
|
|
}
|
|
}
|
|
|
|
public synchronized void
|
|
statusURLLoad(String url, String message, Document doc) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.statusURLLoad(url, message, doc);
|
|
}
|
|
}
|
|
|
|
|
|
public synchronized void
|
|
startDocumentLoad(String url) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.startDocumentLoad(url);
|
|
}
|
|
}
|
|
|
|
public synchronized void
|
|
endDocumentLoad(String url, int status, Document doc) {
|
|
|
|
for (Enumeration e = documentLoadListeners.elements();
|
|
e.hasMoreElements();) {
|
|
DocumentLoadListener listener =
|
|
(DocumentLoadListener) e.nextElement();
|
|
listener.endDocumentLoad(url, status, doc);
|
|
}
|
|
}
|
|
}
|