b0643d1722d5fa02646e44b66355023df2a04513
[jalviewjs.git] / site / swingjs / j2s / org / xml / sax / ext / Attributes2Impl.js
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 () {
4 this.declared = null;
5 this.specified = null;
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$, 
9 function () {
10 Clazz.superConstructor (this, org.xml.sax.ext.Attributes2Impl, []);
11 });
12 Clazz.defineMethod (c$, "isDeclared", 
13 function (index) {
14 if (index < 0 || index >= this.getLength ()) throw  new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
15 return this.declared[index];
16 }, "~N");
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];
22 }, "~S,~S");
23 Clazz.defineMethod (c$, "isDeclared", 
24 function (qName) {
25 var index = this.getIndex (qName);
26 if (index < 0) throw  new IllegalArgumentException ("No such attribute: " + qName);
27 return this.declared[index];
28 }, "~S");
29 Clazz.defineMethod (c$, "isSpecified", 
30 function (index) {
31 if (index < 0 || index >= this.getLength ()) throw  new ArrayIndexOutOfBoundsException ("No attribute at index: " + index);
32 return this.specified[index];
33 }, "~N");
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];
39 }, "~S,~S");
40 Clazz.defineMethod (c$, "isSpecified", 
41 function (qName) {
42 var index = this.getIndex (qName);
43 if (index < 0) throw  new IllegalArgumentException ("No such attribute: " + qName);
44 return this.specified[index];
45 }, "~S");
46 Clazz.defineMethod (c$, "setAttributes", 
47 function (atts) {
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)) {
53 var a2 = atts;
54 for (var i = 0; i < length; i++) {
55 this.declared[i] = a2.isDeclared (i);
56 this.specified[i] = a2.isSpecified (i);
57 }
58 } else {
59 for (var i = 0; i < length; i++) {
60 this.declared[i] = !"CDATA".equals (atts.getType (i));
61 this.specified[i] = true;
62 }
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) {
69 var newFlags;
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);
78 }, "~S,~S,~S,~S,~S");
79 Clazz.defineMethod (c$, "removeAttribute", 
80 function (index) {
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);
86 }}, "~N");
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;
91 }, "~N,~B");
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;
96 }, "~N,~B");
97 });