Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / net / URLConnection.js
1 Clazz.declarePackage ("java.net");
2 Clazz.load (null, "java.net.URLConnection", ["java.lang.IllegalStateException", "$.NullPointerException", "java.net.UnknownServiceException", "JU.Lst"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.url = null;
5 this.doInput = true;
6 this.doOutput = false;
7 this.connected = false;
8 this.requests = null;
9 Clazz.instantialize (this, arguments);
10 }, java.net, "URLConnection");
11 Clazz.defineMethod (c$, "setDoInput", 
12 function (doinput) {
13 if (this.connected) throw  new IllegalStateException ("Already connected");
14 this.doInput = doinput;
15 }, "~B");
16 Clazz.defineMethod (c$, "getDoInput", 
17 function () {
18 return this.doInput;
19 });
20 Clazz.defineMethod (c$, "setDoOutput", 
21 function (dooutput) {
22 if (this.connected) throw  new IllegalStateException ("Already connected");
23 this.doOutput = dooutput;
24 }, "~B");
25 Clazz.defineMethod (c$, "getDoOutput", 
26 function () {
27 return this.doOutput;
28 });
29 Clazz.makeConstructor (c$, 
30 function (url) {
31 this.url = url;
32 }, "java.net.URL");
33 Clazz.defineMethod (c$, "getURL", 
34 function () {
35 return this.url;
36 });
37 Clazz.defineMethod (c$, "getInputStream", 
38 function () {
39 throw  new java.net.UnknownServiceException ("protocol doesn't support input");
40 });
41 Clazz.defineMethod (c$, "getOutputStream", 
42 function () {
43 throw  new java.net.UnknownServiceException ("protocol doesn't support output");
44 });
45 Clazz.defineMethod (c$, "setRequestProperty", 
46 function (key, value) {
47 if (this.connected) throw  new IllegalStateException ("Already connected");
48 if (key == null) throw  new NullPointerException ("key is null");
49 if (this.requests == null) this.requests =  new JU.Lst ();
50 for (var i = this.requests.size (); --i >= 0; ) if (this.requests.get (i)[0].equals (key)) {
51 this.requests.get (i)[1] = value;
52 return;
53 }
54 this.requests.addLast ( Clazz.newArray (-1, [key, value]));
55 }, "~S,~S");
56 });