Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/openscience/miniJmol/DTDResolver.java


1   /*
2    * @(#)DTDResolver.java    1.0 99/06/09
3    *
4    * Copyright (c) 1999 J. Daniel Gezelter All Rights Reserved.
5    *
6    * J. Daniel Gezelter grants you ("Licensee") a non-exclusive, royalty
7    * free, license to use, modify and redistribute this software in
8    * source and binary code form, provided that the following conditions 
9    * are met:
10   *
11   * 1. Redistributions of source code must retain the above copyright
12   *    notice, this list of conditions and the following disclaimer.
13   *
14   * 2. Redistributions in binary form must reproduce the above copyright
15   *    notice, this list of conditions and the following disclaimer in the
16   *    documentation and/or other materials provided with the distribution.
17   *
18   * This software is provided "AS IS," without a warranty of any
19   * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
20   * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
21   * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
22   * EXCLUDED.  J. DANIEL GEZELTER AND HIS LICENSORS SHALL NOT BE LIABLE
23   * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
24   * MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO
25   * EVENT WILL J. DANIEL GEZELTER OR HIS LICENSORS BE LIABLE FOR ANY
26   * LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
27   * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
28   * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
29   * INABILITY TO USE SOFTWARE, EVEN IF J. DANIEL GEZELTER HAS BEEN
30   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31   *
32   * This software is not designed or intended for use in on-line
33   * control of aircraft, air traffic, aircraft navigation or aircraft
34   * communications; or in the design, construction, operation or
35   * maintenance of any nuclear facility. Licensee represents and
36   * warrants that it will not use or redistribute the Software for such
37   * purposes.  
38   */
39  
40  package org.openscience.miniJmol;
41  
42  import org.xml.sax.EntityResolver;
43  import org.xml.sax.InputSource;
44  import java.net.URL;
45  import java.io.*;
46  
47  public class DTDResolver implements EntityResolver {
48  
49      public InputSource resolveEntity (String publicId, String systemId) {
50          String s = new String("");
51          BufferedReader r = new BufferedReader(new StringReader(s));
52          return new InputSource(r);
53      }
54  }
55  /*
56  public class DTDResolver implements EntityResolver {
57   
58          public InputSource resolveEntity (String publicId, String systemId) {
59          if (systemId.equalsIgnoreCase("cml.dtd") || 
60              systemId.equalsIgnoreCase("CML-1999-05-15.dtd")) {
61              try
62                  {
63                      String fname = "org/openscience/miniJmol/Data/cml.dtd";
64  //                    String fname = "cml.dtd";
65                      URL url = getClass().getClassLoader().getResource(fname);
66  //                    URL url = new URL(fname);
67                      InputStream is = url.openStream();
68                      BufferedReader r = new BufferedReader(new InputStreamReader(is));
69                      return new InputSource(r);
70                  }
71              catch(Exception exc) 
72                  {
73                      System.out.println("Error while trying to read CML DTD: " + exc.toString());
74                      return null;
75                  }
76   
77          } else {
78              // use the default behaviour
79              return null;
80          }
81      }    
82  }
83  */