1 Clazz.declarePackage ("org.xml.sax.ext");
2 Clazz.load (["org.xml.sax.ext.Attributes2", "org.xml.sax.helpers.AttributesImpl"], "org.xml.sax.ext.Attributes2Impl", ["java.lang.ArrayIndexOutOfBoundsException", "$.IllegalArgumentException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 Clazz.instantialize (this, arguments);
7 }, org.xml.sax.ext, "Attributes2Impl", org.xml.sax.helpers.AttributesImpl, org.xml.sax.ext.Attributes2);
8 Clazz.makeConstructor (c$,
10 Clazz.superConstructor (this, org.xml.sax.ext.Attributes2Impl, []);
12 Clazz.defineMethod (c$, "isDeclared",
14 if (index < 0 || index >= this.getLength ()) throw new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
15 return this.declared[index];
17 Clazz.defineMethod (c$, "isDeclared",
18 function (uri, localName) {
19 var index = this.getIndex (uri, localName);
20 if (index < 0) throw new IllegalArgumentException ("No such attribute: local=" + localName + ", namespace=" + uri);
21 return this.declared[index];
23 Clazz.defineMethod (c$, "isDeclared",
25 var index = this.getIndex (qName);
26 if (index < 0) throw new IllegalArgumentException ("No such attribute: " + qName);
27 return this.declared[index];
29 Clazz.defineMethod (c$, "isSpecified",
31 if (index < 0 || index >= this.getLength ()) throw new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
32 return this.specified[index];
34 Clazz.defineMethod (c$, "isSpecified",
35 function (uri, localName) {
36 var index = this.getIndex (uri, localName);
37 if (index < 0) throw new IllegalArgumentException ("No such attribute: local=" + localName + ", namespace=" + uri);
38 return this.specified[index];
40 Clazz.defineMethod (c$, "isSpecified",
42 var index = this.getIndex (qName);
43 if (index < 0) throw new IllegalArgumentException ("No such attribute: " + qName);
44 return this.specified[index];
46 Clazz.defineMethod (c$, "setAttributes",
48 var length = atts.getLength ();
49 Clazz.superCall (this, org.xml.sax.ext.Attributes2Impl, "setAttributes", [atts]);
50 this.declared = Clazz.newBooleanArray (length, false);
51 this.specified = Clazz.newBooleanArray (length, false);
52 if (Clazz.instanceOf (atts, org.xml.sax.ext.Attributes2)) {
54 for (var i = 0; i < length; i++) {
55 this.declared[i] = a2.isDeclared (i);
56 this.specified[i] = a2.isSpecified (i);
59 for (var i = 0; i < length; i++) {
60 this.declared[i] = !"CDATA".equals (atts.getType (i));
61 this.specified[i] = true;
63 }}, "org.xml.sax.Attributes");
64 Clazz.defineMethod (c$, "addAttribute",
65 function (uri, localName, qName, type, value) {
66 Clazz.superCall (this, org.xml.sax.ext.Attributes2Impl, "addAttribute", [uri, localName, qName, type, value]);
67 var length = this.getLength ();
68 if (length < this.specified.length) {
70 newFlags = Clazz.newBooleanArray (length, false);
71 System.arraycopy (this.declared, 0, newFlags, 0, this.declared.length);
72 this.declared = newFlags;
73 newFlags = Clazz.newBooleanArray (length, false);
74 System.arraycopy (this.specified, 0, newFlags, 0, this.specified.length);
75 this.specified = newFlags;
76 }this.specified[length - 1] = true;
77 this.declared[length - 1] = !"CDATA".equals (type);
79 Clazz.defineMethod (c$, "removeAttribute",
81 var origMax = this.getLength () - 1;
82 Clazz.superCall (this, org.xml.sax.ext.Attributes2Impl, "removeAttribute", [index]);
83 if (index != origMax) {
84 System.arraycopy (this.declared, index + 1, this.declared, index, origMax - index);
85 System.arraycopy (this.specified, index + 1, this.specified, index, origMax - index);
87 Clazz.defineMethod (c$, "setDeclared",
88 function (index, value) {
89 if (index < 0 || index >= this.getLength ()) throw new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
90 this.declared[index] = value;
92 Clazz.defineMethod (c$, "setSpecified",
93 function (index, value) {
94 if (index < 0 || index >= this.getLength ()) throw new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
95 this.specified[index] = value;