-package javajs.util;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.URL;\r
-import java.net.URLConnection;\r
-\r
-import javajs.api.JmolObjectInterface;\r
-\r
-/**\r
- * \r
- * A method to allow a JavaScript Ajax \r
- * \r
- */\r
-public class AjaxURLConnection extends URLConnection {\r
-\r
- protected AjaxURLConnection(URL url) {\r
- super(url);\r
- }\r
-\r
- byte[] bytesOut;\r
- String postOut = "";\r
-\r
- /**\r
- * \r
- * doAjax() is where the synchronous call to AJAX is to happen. or at least\r
- * where we wait for the asynchronous call to return. This method should fill\r
- * the dataIn field with either a string or byte array, or null if you want to\r
- * throw an error.\r
- * \r
- * url, bytesOut, and postOut are all available for use\r
- * \r
- * the method is "private", but in JavaScript that can still be overloaded.\r
- * Just set something to org.jmol.awtjs.JmolURLConnection.prototype.doAjax\r
- * \r
- * @return file data as a javajs.util.SB or byte[] depending upon the file\r
- * type.\r
- * \r
- * \r
- */\r
- @SuppressWarnings("null")\r
- private Object doAjax() {\r
- JmolObjectInterface jmol = null;\r
- /**\r
- * @j2sNative\r
- * \r
- * jmol = Jmol;\r
- * \r
- */\r
- {\r
- }\r
- return jmol._doAjax(url, postOut, bytesOut);\r
- }\r
-\r
- @Override\r
- public void connect() throws IOException {\r
- // not expected to be used. \r
- }\r
-\r
- public void outputBytes(byte[] bytes) {\r
- // type = "application/octet-stream;";\r
- bytesOut = bytes;\r
- }\r
-\r
- public void outputString(String post) {\r
- postOut = post;\r
- // type = "application/x-www-form-urlencoded";\r
- }\r
-\r
- @Override\r
- public InputStream getInputStream() {\r
- InputStream is = null;\r
- Object o = doAjax();\r
- if (AU.isAB(o))\r
- is = Rdr.getBIS((byte[]) o);\r
- else if (o instanceof SB) \r
- is = Rdr.getBIS(Rdr.getBytesFromSB((SB)o));\r
- else if (o instanceof String)\r
- is = Rdr.getBIS(((String) o).getBytes());\r
- return is;\r
- }\r
- /**\r
- * @return javajs.util.SB or byte[], depending upon the file type\r
- */\r
- public Object getContents() {\r
- return doAjax();\r
- }\r
-\r
-}\r
+package javajs.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javajs.api.JmolObjectInterface;
+
+/**
+ *
+ * A method to allow a JavaScript Ajax
+ *
+ */
+public class AjaxURLConnection extends URLConnection {
+
+ protected AjaxURLConnection(URL url) {
+ super(url);
+ }
+
+ byte[] bytesOut;
+ String postOut = "";
+
+ /**
+ *
+ * doAjax() is where the synchronous call to AJAX is to happen. or at least
+ * where we wait for the asynchronous call to return. This method should fill
+ * the dataIn field with either a string or byte array, or null if you want to
+ * throw an error.
+ *
+ * url, bytesOut, and postOut are all available for use
+ *
+ * the method is "private", but in JavaScript that can still be overloaded.
+ * Just set something to org.jmol.awtjs.JmolURLConnection.prototype.doAjax
+ *
+ * @return file data as a javajs.util.SB or byte[] depending upon the file
+ * type.
+ *
+ *
+ */
+ @SuppressWarnings("null")
+ private Object doAjax() {
+ JmolObjectInterface jmol = null;
+ /**
+ * @j2sNative
+ *
+ * jmol = Jmol;
+ *
+ */
+ {
+ }
+ return jmol._doAjax(url, postOut, bytesOut);
+ }
+
+ @Override
+ public void connect() throws IOException {
+ // not expected to be used.
+ }
+
+ public void outputBytes(byte[] bytes) {
+ // type = "application/octet-stream;";
+ bytesOut = bytes;
+ }
+
+ public void outputString(String post) {
+ postOut = post;
+ // type = "application/x-www-form-urlencoded";
+ }
+
+ @Override
+ public InputStream getInputStream() {
+ InputStream is = null;
+ Object o = doAjax();
+ if (AU.isAB(o))
+ is = Rdr.getBIS((byte[]) o);
+ else if (o instanceof SB)
+ is = Rdr.getBIS(Rdr.getBytesFromSB((SB)o));
+ else if (o instanceof String)
+ is = Rdr.getBIS(((String) o).getBytes());
+ return is;
+ }
+ /**
+ * @return javajs.util.SB or byte[], depending upon the file type
+ */
+ public Object getContents() {
+ return doAjax();
+ }
+
+}