JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / JU / AjaxURLConnection.js
1 Clazz.declarePackage ("JU");\r
2 Clazz.load (["java.net.URLConnection"], "JU.AjaxURLConnection", ["JU.AU", "$.Rdr", "$.SB"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.bytesOut = null;\r
5 this.postOut = "";\r
6 Clazz.instantialize (this, arguments);\r
7 }, JU, "AjaxURLConnection", java.net.URLConnection);\r
8 Clazz.defineMethod (c$, "doAjax", \r
9  function () {\r
10 {\r
11 return Jmol._doAjax(this.url, this.postOut, this.bytesOut);\r
12 }});\r
13 Clazz.overrideMethod (c$, "connect", \r
14 function () {\r
15 });\r
16 Clazz.defineMethod (c$, "outputBytes", \r
17 function (bytes) {\r
18 this.bytesOut = bytes;\r
19 }, "~A");\r
20 Clazz.defineMethod (c$, "outputString", \r
21 function (post) {\r
22 this.postOut = post;\r
23 }, "~S");\r
24 Clazz.overrideMethod (c$, "getInputStream", \r
25 function () {\r
26 var is = null;\r
27 var o = this.doAjax ();\r
28 if (JU.AU.isAB (o)) is = JU.Rdr.getBIS (o);\r
29  else if (Clazz.instanceOf (o, JU.SB)) is = JU.Rdr.getBIS (JU.Rdr.getBytesFromSB (o));\r
30  else if (Clazz.instanceOf (o, String)) is = JU.Rdr.getBIS ((o).getBytes ());\r
31 return is;\r
32 });\r
33 Clazz.defineMethod (c$, "getContents", \r
34 function () {\r
35 return this.doAjax ();\r
36 });\r
37 });\r