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