jdk/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java
changeset 7960 440dbbdb5cbd
parent 6862 f66eb6b6a6b9
child 9035 1255eb81cc2f
equal deleted inserted replaced
7959:2e05332a8f5c 7960:440dbbdb5cbd
    46 
    46 
    47 public class ParserDelegator extends HTMLEditorKit.Parser implements Serializable {
    47 public class ParserDelegator extends HTMLEditorKit.Parser implements Serializable {
    48 
    48 
    49     private static final Object DTD_KEY = new Object();
    49     private static final Object DTD_KEY = new Object();
    50 
    50 
    51     protected static synchronized void setDefaultDTD() {
    51     protected static void setDefaultDTD() {
       
    52         getDefaultDTD();
       
    53     }
       
    54 
       
    55     private static synchronized DTD getDefaultDTD() {
    52         AppContext appContext = AppContext.getAppContext();
    56         AppContext appContext = AppContext.getAppContext();
    53 
    57 
    54         DTD dtd = (DTD) appContext.get(DTD_KEY);
    58         DTD dtd = (DTD) appContext.get(DTD_KEY);
    55 
    59 
    56         if (dtd == null) {
    60         if (dtd == null) {
    65             }
    69             }
    66             dtd = createDTD(_dtd, nm);
    70             dtd = createDTD(_dtd, nm);
    67 
    71 
    68             appContext.put(DTD_KEY, dtd);
    72             appContext.put(DTD_KEY, dtd);
    69         }
    73         }
       
    74 
       
    75         return dtd;
    70     }
    76     }
    71 
    77 
    72     protected static DTD createDTD(DTD dtd, String name) {
    78     protected static DTD createDTD(DTD dtd, String name) {
    73 
    79 
    74         InputStream in = null;
    80         InputStream in = null;
    90     public ParserDelegator() {
    96     public ParserDelegator() {
    91         setDefaultDTD();
    97         setDefaultDTD();
    92     }
    98     }
    93 
    99 
    94     public void parse(Reader r, HTMLEditorKit.ParserCallback cb, boolean ignoreCharSet) throws IOException {
   100     public void parse(Reader r, HTMLEditorKit.ParserCallback cb, boolean ignoreCharSet) throws IOException {
    95         new DocumentParser((DTD) AppContext.getAppContext().get(DTD_KEY)).parse(r, cb, ignoreCharSet);
   101         new DocumentParser(getDefaultDTD()).parse(r, cb, ignoreCharSet);
    96     }
   102     }
    97 
   103 
    98     /**
   104     /**
    99      * Fetch a resource relative to the ParserDelegator classfile.
   105      * Fetch a resource relative to the ParserDelegator classfile.
   100      * If this is called on 1.2 the loading will occur under the
   106      * If this is called on 1.2 the loading will occur under the