JAL-1807 Bob
[jalviewjs.git] / site / j2s / swingjs / JSSAXAttributes.js
1 Clazz.declarePackage ("swingjs");
2 Clazz.load (["org.xml.sax.AttributeList", "org.xml.sax.ext.Attributes2"], "swingjs.JSSAXAttributes", ["java.util.Hashtable", "swingjs.api.DOMNode"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.nodes = null;
5 this.nameMap = null;
6 Clazz.instantialize (this, arguments);
7 }, swingjs, "JSSAXAttributes", null, [org.xml.sax.ext.Attributes2, org.xml.sax.AttributeList]);
8 Clazz.defineMethod (c$, "createNameMap", 
9  function () {
10 this.nameMap =  new java.util.Hashtable ();
11 for (var i = this.nodes.length; --i >= 0; ) {
12 var ii = Integer.$valueOf (i);
13 this.nameMap.put (swingjs.JSSAXAttributes.getFullName (this.getURI (i), this.getLocalName (i), null), ii);
14 this.nameMap.put (this.getQName (i), ii);
15 }
16 });
17 Clazz.makeConstructor (c$, 
18 function (node) {
19 this.nodes = swingjs.api.DOMNode.getAttr (node, "attributes");
20 }, "swingjs.api.DOMNode");
21 Clazz.overrideMethod (c$, "getLength", 
22 function () {
23 return this.nodes.length;
24 });
25 Clazz.defineMethod (c$, "getAttr", 
26  function (index, key) {
27 if (index < 0 || index >= this.nodes.length) return null;
28 var s = swingjs.api.DOMNode.getAttr (this.nodes[index], key);
29 return (s == null ? "" : s);
30 }, "~N,~S");
31 Clazz.overrideMethod (c$, "getURI", 
32 function (index) {
33 return this.getAttr (index, "nameSpaceURI");
34 }, "~N");
35 Clazz.overrideMethod (c$, "getLocalName", 
36 function (index) {
37 return this.getAttr (index, "localName");
38 }, "~N");
39 Clazz.overrideMethod (c$, "getQName", 
40 function (index) {
41 return this.getAttr (index, "nodeName");
42 }, "~N");
43 Clazz.defineMethod (c$, "getType", 
44 function (index) {
45 return "CDATA";
46 }, "~N");
47 Clazz.defineMethod (c$, "getValue", 
48 function (index) {
49 return this.getAttr (index, "value");
50 }, "~N");
51 Clazz.defineMethod (c$, "getIndex", 
52 function (uri, localName) {
53 return this.getIndex2 (uri, localName);
54 }, "~S,~S");
55 Clazz.defineMethod (c$, "getIndex2", 
56 function (uri, localName) {
57 if (this.nameMap == null) this.createNameMap ();
58 var ii = this.nameMap.get (swingjs.JSSAXAttributes.getFullName (uri, localName, null));
59 return (ii == null ? -1 : ii.intValue ());
60 }, "~S,~S");
61 Clazz.defineMethod (c$, "getIndex", 
62 function (qName) {
63 return this.getIndex1 (qName);
64 }, "~S");
65 Clazz.defineMethod (c$, "getIndex1", 
66 function (qName) {
67 if (this.nameMap == null) this.createNameMap ();
68 var ii = this.nameMap.get (qName);
69 return (ii == null ? -1 : ii.intValue ());
70 }, "~S");
71 Clazz.defineMethod (c$, "getType", 
72 function (uri, localName) {
73 var i = this.getIndex2 (uri, localName);
74 return (i < 0 ? null : this.getType (i));
75 }, "~S,~S");
76 Clazz.defineMethod (c$, "getType", 
77 function (qName) {
78 var i = this.getIndex (qName);
79 return (i < 0 ? null : this.getType (i));
80 }, "~S");
81 Clazz.defineMethod (c$, "getValue", 
82 function (uri, localName) {
83 var i = this.getIndex2 (uri, localName);
84 return (i < 0 ? null : this.getType (i));
85 }, "~S,~S");
86 Clazz.defineMethod (c$, "getValue", 
87 function (qName) {
88 var i = this.getIndex (qName);
89 return (i < 0 ? null : this.getValue (i));
90 }, "~S");
91 Clazz.overrideMethod (c$, "getName", 
92 function (i) {
93 return this.getAttr (i, "name");
94 }, "~N");
95 Clazz.defineMethod (c$, "isDeclared", 
96 function (index) {
97 return false;
98 }, "~N");
99 Clazz.defineMethod (c$, "isDeclared", 
100 function (qName) {
101 return false;
102 }, "~S");
103 Clazz.defineMethod (c$, "isDeclared", 
104 function (uri, localName) {
105 return false;
106 }, "~S,~S");
107 Clazz.defineMethod (c$, "isSpecified", 
108 function (index) {
109 return false;
110 }, "~N");
111 Clazz.defineMethod (c$, "isSpecified", 
112 function (uri, localName) {
113 return false;
114 }, "~S,~S");
115 Clazz.defineMethod (c$, "isSpecified", 
116 function (qName) {
117 return false;
118 }, "~S");
119 c$.getFullName = Clazz.defineMethod (c$, "getFullName", 
120 function (uri, localName, qName) {
121 return (uri == null || uri.length == 0 ? "" : uri + "#") + (qName == null || qName.length == 0 || qName.equals (localName) ? localName : qName);
122 }, "~S,~S,~S");
123 });