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