FileDocCategorySizeDatePackage
ParserDelegator.javaAPI DocJava SE 5 API2850Fri Aug 26 14:58:20 BST 2005javax.swing.text.html.parser

ParserDelegator

public class ParserDelegator extends HTMLEditorKit$Parser implements Serializable
Responsible for starting up a new DocumentParser each time its parse method is invoked. Stores a reference to the dtd.
author
Sunita Mani
version
1.15, 12/19/03

Fields Summary
private static DTD
dtd
Constructors Summary
public ParserDelegator()

	if (dtd == null) {
	    setDefaultDTD();
	}
    
Methods Summary
protected static javax.swing.text.html.parser.DTDcreateDTD(javax.swing.text.html.parser.DTD dtd, java.lang.String name)


	InputStream in = null;
	boolean debug = true;
	try {
	    String path = name + ".bdtd";
	    in = getResourceAsStream(path);
            if (in != null) {
                dtd.read(new DataInputStream(new BufferedInputStream(in)));
                dtd.putDTDHash(name, dtd);
	    }
        } catch (Exception e) {
            System.out.println(e);
        }
        return dtd;
    
static java.io.InputStreamgetResourceAsStream(java.lang.String name)
Fetch a resource relative to the ParserDelegator classfile. If this is called on 1.2 the loading will occur under the protection of a doPrivileged call to allow the ParserDelegator to function when used in an applet.

param
name the name of the resource, relative to the ParserDelegator class.
returns
a stream representing the resource

	try {
            return ResourceLoader.getResourceAsStream(name);
	} catch (Throwable e) {
	    // If the class doesn't exist or we have some other 
	    // problem we just try to call getResourceAsStream directly.
	    return ParserDelegator.class.getResourceAsStream(name);
	}
    
public voidparse(java.io.Reader r, javax.swing.text.html.HTMLEditorKit$ParserCallback cb, boolean ignoreCharSet)

	new DocumentParser(dtd).parse(r, cb, ignoreCharSet);
    
private voidreadObject(java.io.ObjectInputStream s)

	s.defaultReadObject();
	if (dtd == null) {
	    setDefaultDTD();
	}
    
protected static synchronized voidsetDefaultDTD()


         
        if (dtd == null) {
	    DTD _dtd = null;
	    // (PENDING) Hate having to hard code!
	    String nm = "html32";
	    try {
		_dtd = DTD.getDTD(nm);
	    } catch (IOException e) {
		// (PENDING) UGLY!
		System.out.println("Throw an exception: could not get default dtd: " + nm);
	    }
	    dtd = createDTD(_dtd, nm);
        }