3 import java.io.IOException;
\r
5 import java.net.URLConnection;
\r
6 import java.net.URLStreamHandler;
\r
12 * A method to allow a JavaScript AJAX adapter to
\r
13 * deliver web content to JSmol. This handler is just a formality.
\r
16 public class AjaxURLStreamHandler extends URLStreamHandler {
\r
20 public AjaxURLStreamHandler(String protocol) {
\r
21 this.protocol = protocol;
\r
25 protected URLConnection openConnection(URL url) throws IOException {
\r
26 return new AjaxURLConnection(url);
\r
31 protected String toExternalForm(URL u) {
\r
32 SB result = new SB();
\r
33 result.append(u.getProtocol());
\r
35 if (u.getAuthority() != null && u.getAuthority().length() > 0) {
\r
36 result.append("//");
\r
37 result.append(u.getAuthority());
\r
39 if (u.getPath() != null) {
\r
40 result.append(u.getPath());
\r
42 if (u.getQuery() != null) {
\r
44 result.append(u.getQuery());
\r
46 if (u.getRef() != null) {
\r
48 result.append(u.getRef());
\r
50 return result.toString();
\r