src/share/classes/javax/swing/text/html/parser/ParserDelegator.java

Print this page




  26 package javax.swing.text.html.parser;
  27 
  28 import sun.awt.AppContext;
  29 
  30 import javax.swing.text.html.HTMLEditorKit;
  31 import java.io.BufferedInputStream;
  32 import java.io.IOException;
  33 import java.io.InputStream;
  34 import java.io.DataInputStream;
  35 import java.io.ObjectInputStream;
  36 import java.io.Reader;
  37 import java.io.Serializable;
  38 
  39 /**
  40  * Responsible for starting up a new DocumentParser
  41  * each time its parse method is invoked. Stores a
  42  * reference to the dtd.
  43  *
  44  * @author  Sunita Mani
  45  */
  46 
  47 public class ParserDelegator extends HTMLEditorKit.Parser implements Serializable {
  48 
  49     private static final Object DTD_KEY = new Object();
  50 
  51     protected static void setDefaultDTD() {
  52         getDefaultDTD();
  53     }
  54 
  55     private static synchronized DTD getDefaultDTD() {
  56         AppContext appContext = AppContext.getAppContext();
  57 
  58         DTD dtd = (DTD) appContext.get(DTD_KEY);
  59 
  60         if (dtd == null) {
  61             DTD _dtd = null;
  62             // (PENDING) Hate having to hard code!
  63             String nm = "html32";
  64             try {
  65                 _dtd = DTD.getDTD(nm);
  66             } catch (IOException e) {
  67                 // (PENDING) UGLY!
  68                 System.out.println("Throw an exception: could not get default dtd: " + nm);




  26 package javax.swing.text.html.parser;
  27 
  28 import sun.awt.AppContext;
  29 
  30 import javax.swing.text.html.HTMLEditorKit;
  31 import java.io.BufferedInputStream;
  32 import java.io.IOException;
  33 import java.io.InputStream;
  34 import java.io.DataInputStream;
  35 import java.io.ObjectInputStream;
  36 import java.io.Reader;
  37 import java.io.Serializable;
  38 
  39 /**
  40  * Responsible for starting up a new DocumentParser
  41  * each time its parse method is invoked. Stores a
  42  * reference to the dtd.
  43  *
  44  * @author  Sunita Mani
  45  */
  46 @SuppressWarnings("serial") // Same-version serialization only
  47 public class ParserDelegator extends HTMLEditorKit.Parser implements Serializable {

  48     private static final Object DTD_KEY = new Object();
  49 
  50     protected static void setDefaultDTD() {
  51         getDefaultDTD();
  52     }
  53 
  54     private static synchronized DTD getDefaultDTD() {
  55         AppContext appContext = AppContext.getAppContext();
  56 
  57         DTD dtd = (DTD) appContext.get(DTD_KEY);
  58 
  59         if (dtd == null) {
  60             DTD _dtd = null;
  61             // (PENDING) Hate having to hard code!
  62             String nm = "html32";
  63             try {
  64                 _dtd = DTD.getDTD(nm);
  65             } catch (IOException e) {
  66                 // (PENDING) UGLY!
  67                 System.out.println("Throw an exception: could not get default dtd: " + nm);