e0e6b68aba3158134f8e8300b7526242e43f32ff
[jalviewjs.git] / site / j2s / org / xml / sax / helpers / AttributesImpl.js
1 Clazz.declarePackage ("org.xml.sax.helpers");
2 Clazz.load (["org.xml.sax.Attributes"], "org.xml.sax.helpers.AttributesImpl", ["java.lang.ArrayIndexOutOfBoundsException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.length = 0;
5 this.data = null;
6 Clazz.instantialize (this, arguments);
7 }, org.xml.sax.helpers, "AttributesImpl", null, org.xml.sax.Attributes);
8 Clazz.makeConstructor (c$, 
9 function () {
10 this.length = 0;
11 this.data = null;
12 });
13 Clazz.makeConstructor (c$, 
14 function (atts) {
15 this.setAttributes (atts);
16 }, "org.xml.sax.Attributes");
17 Clazz.defineMethod (c$, "getLength", 
18 function () {
19 return this.length;
20 });
21 Clazz.defineMethod (c$, "getURI", 
22 function (index) {
23 if (index >= 0 && index < this.length) {
24 return this.data[index * 5];
25 } else {
26 return null;
27 }}, "~N");
28 Clazz.defineMethod (c$, "getLocalName", 
29 function (index) {
30 if (index >= 0 && index < this.length) {
31 return this.data[index * 5 + 1];
32 } else {
33 return null;
34 }}, "~N");
35 Clazz.defineMethod (c$, "getQName", 
36 function (index) {
37 if (index >= 0 && index < this.length) {
38 return this.data[index * 5 + 2];
39 } else {
40 return null;
41 }}, "~N");
42 Clazz.defineMethod (c$, "getType", 
43 function (index) {
44 if (index >= 0 && index < this.length) {
45 return this.data[index * 5 + 3];
46 } else {
47 return null;
48 }}, "~N");
49 Clazz.defineMethod (c$, "getValue", 
50 function (index) {
51 if (index >= 0 && index < this.length) {
52 return this.data[index * 5 + 4];
53 } else {
54 return null;
55 }}, "~N");
56 Clazz.defineMethod (c$, "getIndex", 
57 function (uri, localName) {
58 var max = this.length * 5;
59 for (var i = 0; i < max; i += 5) {
60 if (this.data[i].equals (uri) && this.data[i + 1].equals (localName)) {
61 return Clazz.doubleToInt (i / 5);
62 }}
63 return -1;
64 }, "~S,~S");
65 Clazz.defineMethod (c$, "getIndex", 
66 function (qName) {
67 var max = this.length * 5;
68 for (var i = 0; i < max; i += 5) {
69 if (this.data[i + 2].equals (qName)) {
70 return Clazz.doubleToInt (i / 5);
71 }}
72 return -1;
73 }, "~S");
74 Clazz.defineMethod (c$, "getType", 
75 function (uri, localName) {
76 var max = this.length * 5;
77 for (var i = 0; i < max; i += 5) {
78 if (this.data[i].equals (uri) && this.data[i + 1].equals (localName)) {
79 return this.data[i + 3];
80 }}
81 return null;
82 }, "~S,~S");
83 Clazz.defineMethod (c$, "getType", 
84 function (qName) {
85 var max = this.length * 5;
86 for (var i = 0; i < max; i += 5) {
87 if (this.data[i + 2].equals (qName)) {
88 return this.data[i + 3];
89 }}
90 return null;
91 }, "~S");
92 Clazz.defineMethod (c$, "getValue", 
93 function (uri, localName) {
94 var max = this.length * 5;
95 for (var i = 0; i < max; i += 5) {
96 if (this.data[i].equals (uri) && this.data[i + 1].equals (localName)) {
97 return this.data[i + 4];
98 }}
99 return null;
100 }, "~S,~S");
101 Clazz.defineMethod (c$, "getValue", 
102 function (qName) {
103 var max = this.length * 5;
104 for (var i = 0; i < max; i += 5) {
105 if (this.data[i + 2].equals (qName)) {
106 return this.data[i + 4];
107 }}
108 return null;
109 }, "~S");
110 Clazz.defineMethod (c$, "clear", 
111 function () {
112 if (this.data != null) {
113 for (var i = 0; i < (this.length * 5); i++) this.data[i] = null;
114
115 }this.length = 0;
116 });
117 Clazz.defineMethod (c$, "setAttributes", 
118 function (atts) {
119 this.clear ();
120 this.length = atts.getLength ();
121 if (this.length > 0) {
122 this.data =  new Array (this.length * 5);
123 for (var i = 0; i < this.length; i++) {
124 this.data[i * 5] = atts.getURI (i);
125 this.data[i * 5 + 1] = atts.getLocalName (i);
126 this.data[i * 5 + 2] = atts.getQName (i);
127 this.data[i * 5 + 3] = atts.getType (i);
128 this.data[i * 5 + 4] = atts.getValue (i);
129 }
130 }}, "org.xml.sax.Attributes");
131 Clazz.defineMethod (c$, "addAttribute", 
132 function (uri, localName, qName, type, value) {
133 this.ensureCapacity (this.length + 1);
134 this.data[this.length * 5] = uri;
135 this.data[this.length * 5 + 1] = localName;
136 this.data[this.length * 5 + 2] = qName;
137 this.data[this.length * 5 + 3] = type;
138 this.data[this.length * 5 + 4] = value;
139 this.length++;
140 }, "~S,~S,~S,~S,~S");
141 Clazz.defineMethod (c$, "setAttribute", 
142 function (index, uri, localName, qName, type, value) {
143 if (index >= 0 && index < this.length) {
144 this.data[index * 5] = uri;
145 this.data[index * 5 + 1] = localName;
146 this.data[index * 5 + 2] = qName;
147 this.data[index * 5 + 3] = type;
148 this.data[index * 5 + 4] = value;
149 } else {
150 this.badIndex (index);
151 }}, "~N,~S,~S,~S,~S,~S");
152 Clazz.defineMethod (c$, "removeAttribute", 
153 function (index) {
154 if (index >= 0 && index < this.length) {
155 if (index < this.length - 1) {
156 System.arraycopy (this.data, (index + 1) * 5, this.data, index * 5, (this.length - index - 1) * 5);
157 }index = (this.length - 1) * 5;
158 this.data[index++] = null;
159 this.data[index++] = null;
160 this.data[index++] = null;
161 this.data[index++] = null;
162 this.data[index] = null;
163 this.length--;
164 } else {
165 this.badIndex (index);
166 }}, "~N");
167 Clazz.defineMethod (c$, "setURI", 
168 function (index, uri) {
169 if (index >= 0 && index < this.length) {
170 this.data[index * 5] = uri;
171 } else {
172 this.badIndex (index);
173 }}, "~N,~S");
174 Clazz.defineMethod (c$, "setLocalName", 
175 function (index, localName) {
176 if (index >= 0 && index < this.length) {
177 this.data[index * 5 + 1] = localName;
178 } else {
179 this.badIndex (index);
180 }}, "~N,~S");
181 Clazz.defineMethod (c$, "setQName", 
182 function (index, qName) {
183 if (index >= 0 && index < this.length) {
184 this.data[index * 5 + 2] = qName;
185 } else {
186 this.badIndex (index);
187 }}, "~N,~S");
188 Clazz.defineMethod (c$, "setType", 
189 function (index, type) {
190 if (index >= 0 && index < this.length) {
191 this.data[index * 5 + 3] = type;
192 } else {
193 this.badIndex (index);
194 }}, "~N,~S");
195 Clazz.defineMethod (c$, "setValue", 
196 function (index, value) {
197 if (index >= 0 && index < this.length) {
198 this.data[index * 5 + 4] = value;
199 } else {
200 this.badIndex (index);
201 }}, "~N,~S");
202 Clazz.defineMethod (c$, "ensureCapacity", 
203  function (n) {
204 if (n <= 0) {
205 return;
206 }var max;
207 if (this.data == null || this.data.length == 0) {
208 max = 25;
209 } else if (this.data.length >= n * 5) {
210 return;
211 } else {
212 max = this.data.length;
213 }while (max < n * 5) {
214 max *= 2;
215 }
216 var newData =  new Array (max);
217 if (this.length > 0) {
218 System.arraycopy (this.data, 0, newData, 0, this.length * 5);
219 }this.data = newData;
220 }, "~N");
221 Clazz.defineMethod (c$, "badIndex", 
222  function (index) {
223 var msg = "Attempt to modify attribute at illegal index: " + index;
224 throw  new ArrayIndexOutOfBoundsException (msg);
225 }, "~N");
226 });