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