1 Clazz.declarePackage ("java.util");
2 Clazz.load (["java.util.Hashtable"], "java.util.Properties", ["java.lang.IllegalArgumentException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 if (!Clazz.isClassDefined ("java.util.Properties.LineReader")) {
6 java.util.Properties.$Properties$LineReader$ ();
8 Clazz.instantialize (this, arguments);
9 }, java.util, "Properties", java.util.Hashtable);
10 Clazz.makeConstructor (c$,
12 this.construct (null);
14 Clazz.makeConstructor (c$,
16 Clazz.superConstructor (this, java.util.Properties, []);
17 this.defaults = defaults;
18 }, "java.util.Properties");
19 Clazz.defineMethod (c$, "setProperty",
20 function (key, value) {
21 return this.put (key, value);
23 Clazz.defineMethod (c$, "load",
25 this.load0 (Clazz.innerTypeInstance (java.util.Properties.LineReader, this, null, reader));
27 Clazz.defineMethod (c$, "load",
29 this.load0 (Clazz.innerTypeInstance (java.util.Properties.LineReader, this, null, inStream));
30 }, "java.io.InputStream");
31 Clazz.defineMethod (c$, "load0",
33 var convtBuf = Clazz.newCharArray (1024, '\0');
39 var precedingBackslash;
40 while ((limit = lr.readLine ()) >= 0) {
41 c = String.fromCharCode ( 0);
45 precedingBackslash = false;
46 while (keyLen < limit) {
47 c = lr.lineBuf[keyLen];
48 if ((c == '=' || c == ':') && !precedingBackslash) {
49 valueStart = keyLen + 1;
52 } else if ((c == ' ' || c == '\t' || c == '\f') && !precedingBackslash) {
53 valueStart = keyLen + 1;
56 precedingBackslash = !precedingBackslash;
58 precedingBackslash = false;
61 while (valueStart < limit) {
62 c = lr.lineBuf[valueStart];
63 if (c != ' ' && c != '\t' && c != '\f') {
64 if (!hasSep && (c == '=' || c == ':')) {
70 var key = this.loadConvert (lr.lineBuf, 0, keyLen, convtBuf);
71 var value = this.loadConvert (lr.lineBuf, valueStart, limit - valueStart, convtBuf);
72 this.put (key, value);
74 }, "java.util.Properties.LineReader");
75 Clazz.defineMethod (c$, "loadConvert",
76 function ($in, off, len, convtBuf) {
77 if (convtBuf.length < len) {
81 }convtBuf = Clazz.newCharArray (newLen, '\0');
92 for (var i = 0; i < 4; i++) {
105 value = (value << 4) + aChar.charCodeAt (0) - 48;
113 value = (value << 4) + 10 + aChar.charCodeAt (0) - 97;
121 value = (value << 4) + 10 + aChar.charCodeAt (0) - 65;
124 throw new IllegalArgumentException ("Malformed \\uxxxx encoding.");
127 out[outLen++] = String.fromCharCode (value);
129 if (aChar == 't') aChar = '\t';
130 else if (aChar == 'r') aChar = '\r';
131 else if (aChar == 'n') aChar = '\n';
132 else if (aChar == 'f') aChar = '\f';
133 out[outLen++] = aChar;
135 out[outLen++] = aChar;
137 return String.instantialize (out, 0, outLen);
139 Clazz.defineMethod (c$, "getProperty",
141 var oval = Clazz.superCall (this, java.util.Properties, "get", [key]);
142 var sval = (Clazz.instanceOf (oval, String)) ? oval : null;
143 return ((sval == null) && (this.defaults != null)) ? this.defaults.getProperty (key) : sval;
145 Clazz.defineMethod (c$, "getProperty",
146 function (key, defaultValue) {
147 var val = this.getProperty (key);
148 return (val == null) ? defaultValue : val;
150 Clazz.defineMethod (c$, "propertyNames",
152 var h = new java.util.Hashtable ();
156 Clazz.defineMethod (c$, "stringPropertyNames",
158 var h = new java.util.Hashtable ();
159 this.enumerateStringProperties (h);
162 Clazz.defineMethod (c$, "enumerate",
164 if (this.defaults != null) {
165 this.defaults.enumerate (h);
166 }for (var e = this.keys (); e.hasMoreElements (); ) {
167 var key = e.nextElement ();
168 h.put (key, this.get (key));
170 }, "java.util.Hashtable");
171 Clazz.defineMethod (c$, "enumerateStringProperties",
173 if (this.defaults != null) {
174 this.defaults.enumerateStringProperties (h);
175 }for (var e = this.keys (); e.hasMoreElements (); ) {
176 var k = e.nextElement ();
177 var v = this.get (k);
178 if (Clazz.instanceOf (k, String) && Clazz.instanceOf (v, String)) {
181 }, "java.util.Hashtable");
182 c$.$Properties$LineReader$ = function () {
184 c$ = Clazz.decorateAsClass (function () {
185 Clazz.prepareCallback (this, arguments);
186 this.inByteBuf = null;
187 this.inCharBuf = null;
191 this.inStream = null;
193 Clazz.instantialize (this, arguments);
194 }, java.util.Properties, "LineReader");
195 Clazz.prepareFields (c$, function () {
196 this.lineBuf = Clazz.newCharArray (1024, '\0');
198 Clazz.makeConstructor (c$,
201 this.inByteBuf = Clazz.newByteArray (8192, 0);
202 }, "java.io.InputStream");
203 Clazz.makeConstructor (c$,
206 this.inCharBuf = Clazz.newCharArray (8192, '\0');
207 }, "java.io.Reader");
208 Clazz.defineMethod (c$, "readLine",
211 var b = String.fromCharCode (0);
219 if (this.inOff >= this.inLimit) {
220 this.inLimit = (this.inStream == null) ? this.reader.read (this.inCharBuf) : this.inStream.read (this.inByteBuf);
222 if (this.inLimit <= 0) {
226 }}if (this.inStream != null) {
227 b = String.fromCharCode (0xff & this.inByteBuf[this.inOff++]);
229 b = this.inCharBuf[this.inOff++];
235 if (b == ' ' || b == '\t' || b == '\f') {
237 }if (!f && (b == '\r' || b == '\n')) {
243 if (b == '#' || b == '!') {
246 }}if (b != '\n' && b != '\r') {
247 this.lineBuf[a++] = b;
248 if (a == this.lineBuf.length) {
249 var i = this.lineBuf.length * 2;
251 }var j = Clazz.newCharArray (i, '\0');
252 System.arraycopy (this.lineBuf, 0, j, 0, this.lineBuf.length);
265 }if (this.inOff >= this.inLimit) {
266 this.inLimit = (this.inStream == null) ? this.reader.read (this.inCharBuf) : this.inStream.read (this.inByteBuf);
268 if (this.inLimit <= 0) {