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 () {
5 this.currentContext = null;
7 this.namespaceDeclUris = false;
8 if (!Clazz.isClassDefined ("org.xml.sax.helpers.NamespaceSupport.Context")) {
9 org.xml.sax.helpers.NamespaceSupport.$NamespaceSupport$Context$ ();
11 Clazz.instantialize (this, arguments);
12 }, org.xml.sax.helpers, "NamespaceSupport");
13 Clazz.makeConstructor (c$,
17 Clazz.defineMethod (c$, "reset",
19 this.contexts = new Array (32);
20 this.namespaceDeclUris = false;
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");
25 Clazz.defineMethod (c$, "pushContext",
27 var max = this.contexts.length;
28 this.contexts[this.contextPos].declsOK = false;
30 if (this.contextPos >= max) {
31 var newContexts = new Array (max * 2);
32 System.arraycopy (this.contexts, 0, newContexts, 0, max);
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]);
41 Clazz.defineMethod (c$, "popContext",
43 this.contexts[this.contextPos].clear ();
45 if (this.contextPos < 0) {
46 throw new java.util.EmptyStackException ();
47 }this.currentContext = this.contexts[this.contextPos];
49 Clazz.defineMethod (c$, "declarePrefix",
50 function (prefix, uri) {
51 if (prefix.equals ("xml") || prefix.equals ("xmlns")) {
54 this.currentContext.declarePrefix (prefix, uri);
57 Clazz.defineMethod (c$, "processName",
58 function (qName, parts, isAttribute) {
59 var myParts = this.currentContext.processName (qName, isAttribute);
60 if (myParts == null) {
63 parts[0] = myParts[0];
64 parts[1] = myParts[1];
65 parts[2] = myParts[2];
68 Clazz.defineMethod (c$, "getURI",
70 return this.currentContext.getURI (prefix);
72 Clazz.defineMethod (c$, "getPrefixes",
74 return this.currentContext.getPrefixes ();
76 Clazz.defineMethod (c$, "getPrefix",
78 return this.currentContext.getPrefix (uri);
80 Clazz.defineMethod (c$, "getPrefixes",
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);
89 return prefixes.elements ();
91 Clazz.defineMethod (c$, "getDeclaredPrefixes",
93 return this.currentContext.getDeclaredPrefixes ();
95 Clazz.defineMethod (c$, "setNamespaceDeclUris",
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/");
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");
105 Clazz.defineMethod (c$, "isNamespaceDeclUris",
107 return this.namespaceDeclUris;
109 c$.$NamespaceSupport$Context$ = function () {
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;
119 this.declarations = null;
120 this.declSeen = false;
122 Clazz.instantialize (this, arguments);
123 }, org.xml.sax.helpers.NamespaceSupport, "Context");
124 Clazz.makeConstructor (c$,
128 Clazz.defineMethod (c$, "setParent",
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;
139 }, "org.xml.sax.helpers.NamespaceSupport.Context");
140 Clazz.defineMethod (c$, "clear",
143 this.prefixTable = null;
144 this.uriTable = null;
145 this.elementNameTable = null;
146 this.attributeNameTable = null;
147 this.defaultNS = null;
149 Clazz.defineMethod (c$, "declarePrefix",
151 if (!this.declsOK) throw new IllegalStateException ("can't declare any more prefixes in this context");
152 if (!this.declSeen) {
154 }if (this.declarations == null) {
155 this.declarations = new java.util.Vector ();
160 this.defaultNS = null;
164 this.prefixTable.put (a, b);
165 this.uriTable.put (b, a);
166 }this.declarations.addElement (a);
168 Clazz.defineMethod (c$, "processName",
172 this.declsOK = false;
174 d = this.attributeNameTable;
176 d = this.elementNameTable;
182 var e = a.indexOf (':');
185 if (a === "xmlns" && this.b$["org.xml.sax.helpers.NamespaceSupport"].namespaceDeclUris) c[0] = "http://www.w3.org/xmlns/2000/";
187 } else if (this.defaultNS == null) {
190 c[0] = this.defaultNS;
193 var f = a.substring (0, e);
194 var g = a.substring (e + 1);
199 h = this.prefixTable.get (f);
200 }if (h == null || (!b && "xmlns".equals (f))) {
207 Clazz.defineMethod (c$, "getURI",
210 return this.defaultNS;
211 } else if (this.prefixTable == null) {
214 return this.prefixTable.get (a);
216 Clazz.defineMethod (c$, "getPrefix",
218 if (this.uriTable == null) {
221 return this.uriTable.get (a);
223 Clazz.defineMethod (c$, "getDeclaredPrefixes",
225 if (this.declarations == null) {
226 return org.xml.sax.helpers.NamespaceSupport.EMPTY_ENUMERATION;
228 return this.declarations.elements ();
230 Clazz.defineMethod (c$, "getPrefixes",
232 if (this.prefixTable == null) {
233 return org.xml.sax.helpers.NamespaceSupport.EMPTY_ENUMERATION;
235 return this.prefixTable.keys ();
237 Clazz.defineMethod (c$, "copyTables",
239 if (this.prefixTable != null) {
240 this.prefixTable = this.prefixTable.clone ();
242 this.prefixTable = new java.util.Hashtable ();
243 }if (this.uriTable != null) {
244 this.uriTable = this.uriTable.clone ();
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;
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 ();