715127e5da35b04f66b60813c8cbe908a4a7ad66
[jalviewjs.git] / site / swingjs / j2s / org / xml / sax / helpers / NamespaceSupport.js
1 Clazz.declarePackage ("org.xml.sax.helpers");
2 Clazz.load (["java.util.Vector"], "org.xml.sax.helpers.NamespaceSupport", ["java.lang.IllegalStateException", "java.util.EmptyStackException", "$.Hashtable"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.contexts = null;
5 this.currentContext = null;
6 this.contextPos = 0;
7 this.namespaceDeclUris = false;
8 if (!Clazz.isClassDefined ("org.xml.sax.helpers.NamespaceSupport.Context")) {
9 org.xml.sax.helpers.NamespaceSupport.$NamespaceSupport$Context$ ();
10 }
11 Clazz.instantialize (this, arguments);
12 }, org.xml.sax.helpers, "NamespaceSupport");
13 Clazz.makeConstructor (c$, 
14 function () {
15 this.reset ();
16 });
17 Clazz.defineMethod (c$, "reset", 
18 function () {
19 this.contexts =  new Array (32);
20 this.namespaceDeclUris = false;
21 this.contextPos = 0;
22 this.contexts[this.contextPos] = this.currentContext = Clazz.innerTypeInstance (org.xml.sax.helpers.NamespaceSupport.Context, this, null);
23 this.currentContext.declarePrefix ("xml", "http://www.w3.org/XML/1998/namespace");
24 });
25 Clazz.defineMethod (c$, "pushContext", 
26 function () {
27 var max = this.contexts.length;
28 this.contexts[this.contextPos].declsOK = false;
29 this.contextPos++;
30 if (this.contextPos >= max) {
31 var newContexts =  new Array (max * 2);
32 System.arraycopy (this.contexts, 0, newContexts, 0, max);
33 max *= 2;
34 this.contexts = newContexts;
35 }this.currentContext = this.contexts[this.contextPos];
36 if (this.currentContext == null) {
37 this.contexts[this.contextPos] = this.currentContext = Clazz.innerTypeInstance (org.xml.sax.helpers.NamespaceSupport.Context, this, null);
38 }if (this.contextPos > 0) {
39 this.currentContext.setParent (this.contexts[this.contextPos - 1]);
40 }});
41 Clazz.defineMethod (c$, "popContext", 
42 function () {
43 this.contexts[this.contextPos].clear ();
44 this.contextPos--;
45 if (this.contextPos < 0) {
46 throw  new java.util.EmptyStackException ();
47 }this.currentContext = this.contexts[this.contextPos];
48 });
49 Clazz.defineMethod (c$, "declarePrefix", 
50 function (prefix, uri) {
51 if (prefix.equals ("xml") || prefix.equals ("xmlns")) {
52 return false;
53 } else {
54 this.currentContext.declarePrefix (prefix, uri);
55 return true;
56 }}, "~S,~S");
57 Clazz.defineMethod (c$, "processName", 
58 function (qName, parts, isAttribute) {
59 var myParts = this.currentContext.processName (qName, isAttribute);
60 if (myParts == null) {
61 return null;
62 } else {
63 parts[0] = myParts[0];
64 parts[1] = myParts[1];
65 parts[2] = myParts[2];
66 return parts;
67 }}, "~S,~A,~B");
68 Clazz.defineMethod (c$, "getURI", 
69 function (prefix) {
70 return this.currentContext.getURI (prefix);
71 }, "~S");
72 Clazz.defineMethod (c$, "getPrefixes", 
73 function () {
74 return this.currentContext.getPrefixes ();
75 });
76 Clazz.defineMethod (c$, "getPrefix", 
77 function (uri) {
78 return this.currentContext.getPrefix (uri);
79 }, "~S");
80 Clazz.defineMethod (c$, "getPrefixes", 
81 function (uri) {
82 var prefixes =  new java.util.Vector ();
83 var allPrefixes = this.getPrefixes ();
84 while (allPrefixes.hasMoreElements ()) {
85 var prefix = allPrefixes.nextElement ();
86 if (uri.equals (this.getURI (prefix))) {
87 prefixes.addElement (prefix);
88 }}
89 return prefixes.elements ();
90 }, "~S");
91 Clazz.defineMethod (c$, "getDeclaredPrefixes", 
92 function () {
93 return this.currentContext.getDeclaredPrefixes ();
94 });
95 Clazz.defineMethod (c$, "setNamespaceDeclUris", 
96 function (value) {
97 if (this.contextPos != 0) throw  new IllegalStateException ();
98 if (value == this.namespaceDeclUris) return;
99 this.namespaceDeclUris = value;
100 if (value) this.currentContext.declarePrefix ("xmlns", "http://www.w3.org/xmlns/2000/");
101  else {
102 this.contexts[this.contextPos] = this.currentContext = Clazz.innerTypeInstance (org.xml.sax.helpers.NamespaceSupport.Context, this, null);
103 this.currentContext.declarePrefix ("xml", "http://www.w3.org/XML/1998/namespace");
104 }}, "~B");
105 Clazz.defineMethod (c$, "isNamespaceDeclUris", 
106 function () {
107 return this.namespaceDeclUris;
108 });
109 c$.$NamespaceSupport$Context$ = function () {
110 Clazz.pu$h(self.c$);
111 c$ = Clazz.decorateAsClass (function () {
112 Clazz.prepareCallback (this, arguments);
113 this.prefixTable = null;
114 this.uriTable = null;
115 this.elementNameTable = null;
116 this.attributeNameTable = null;
117 this.defaultNS = null;
118 this.declsOK = true;
119 this.declarations = null;
120 this.declSeen = false;
121 this.parent = null;
122 Clazz.instantialize (this, arguments);
123 }, org.xml.sax.helpers.NamespaceSupport, "Context");
124 Clazz.makeConstructor (c$, 
125 function () {
126 this.copyTables ();
127 });
128 Clazz.defineMethod (c$, "setParent", 
129 function (a) {
130 this.parent = a;
131 this.declarations = null;
132 this.prefixTable = a.prefixTable;
133 this.uriTable = a.uriTable;
134 this.elementNameTable = a.elementNameTable;
135 this.attributeNameTable = a.attributeNameTable;
136 this.defaultNS = a.defaultNS;
137 this.declSeen = false;
138 this.declsOK = true;
139 }, "org.xml.sax.helpers.NamespaceSupport.Context");
140 Clazz.defineMethod (c$, "clear", 
141 function () {
142 this.parent = null;
143 this.prefixTable = null;
144 this.uriTable = null;
145 this.elementNameTable = null;
146 this.attributeNameTable = null;
147 this.defaultNS = null;
148 });
149 Clazz.defineMethod (c$, "declarePrefix", 
150 function (a, b) {
151 if (!this.declsOK) throw  new IllegalStateException ("can't declare any more prefixes in this context");
152 if (!this.declSeen) {
153 this.copyTables ();
154 }if (this.declarations == null) {
155 this.declarations =  new java.util.Vector ();
156 }a = a.intern ();
157 b = b.intern ();
158 if ("".equals (a)) {
159 if ("".equals (b)) {
160 this.defaultNS = null;
161 } else {
162 this.defaultNS = b;
163 }} else {
164 this.prefixTable.put (a, b);
165 this.uriTable.put (b, a);
166 }this.declarations.addElement (a);
167 }, "~S,~S");
168 Clazz.defineMethod (c$, "processName", 
169 function (a, b) {
170 var c;
171 var d;
172 this.declsOK = false;
173 if (b) {
174 d = this.attributeNameTable;
175 } else {
176 d = this.elementNameTable;
177 }c = d.get (a);
178 if (c != null) {
179 return c;
180 }c =  new Array (3);
181 c[2] = a.intern ();
182 var e = a.indexOf (':');
183 if (e == -1) {
184 if (b) {
185 if (a === "xmlns" && this.b$["org.xml.sax.helpers.NamespaceSupport"].namespaceDeclUris) c[0] = "http://www.w3.org/xmlns/2000/";
186  else c[0] = "";
187 } else if (this.defaultNS == null) {
188 c[0] = "";
189 } else {
190 c[0] = this.defaultNS;
191 }c[1] = c[2];
192 } else {
193 var f = a.substring (0, e);
194 var g = a.substring (e + 1);
195 var h;
196 if ("".equals (f)) {
197 h = this.defaultNS;
198 } else {
199 h = this.prefixTable.get (f);
200 }if (h == null || (!b && "xmlns".equals (f))) {
201 return null;
202 }c[0] = h;
203 c[1] = g.intern ();
204 }d.put (c[2], c);
205 return c;
206 }, "~S,~B");
207 Clazz.defineMethod (c$, "getURI", 
208 function (a) {
209 if ("".equals (a)) {
210 return this.defaultNS;
211 } else if (this.prefixTable == null) {
212 return null;
213 } else {
214 return this.prefixTable.get (a);
215 }}, "~S");
216 Clazz.defineMethod (c$, "getPrefix", 
217 function (a) {
218 if (this.uriTable == null) {
219 return null;
220 } else {
221 return this.uriTable.get (a);
222 }}, "~S");
223 Clazz.defineMethod (c$, "getDeclaredPrefixes", 
224 function () {
225 if (this.declarations == null) {
226 return org.xml.sax.helpers.NamespaceSupport.EMPTY_ENUMERATION;
227 } else {
228 return this.declarations.elements ();
229 }});
230 Clazz.defineMethod (c$, "getPrefixes", 
231 function () {
232 if (this.prefixTable == null) {
233 return org.xml.sax.helpers.NamespaceSupport.EMPTY_ENUMERATION;
234 } else {
235 return this.prefixTable.keys ();
236 }});
237 Clazz.defineMethod (c$, "copyTables", 
238  function () {
239 if (this.prefixTable != null) {
240 this.prefixTable = this.prefixTable.clone ();
241 } else {
242 this.prefixTable =  new java.util.Hashtable ();
243 }if (this.uriTable != null) {
244 this.uriTable = this.uriTable.clone ();
245 } else {
246 this.uriTable =  new java.util.Hashtable ();
247 }this.elementNameTable =  new java.util.Hashtable ();
248 this.attributeNameTable =  new java.util.Hashtable ();
249 this.declSeen = true;
250 });
251 c$ = Clazz.p0p ();
252 };
253 Clazz.defineStatics (c$,
254 "XMLNS", "http://www.w3.org/XML/1998/namespace",
255 "NSDECL", "http://www.w3.org/xmlns/2000/");
256 c$.EMPTY_ENUMERATION = c$.prototype.EMPTY_ENUMERATION =  new java.util.Vector ().elements ();
257 });