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