1 Clazz.declarePackage ("org.xml.sax.helpers");
\r
2 Clazz.load (["org.xml.sax.Attributes", "$.DocumentHandler", "$.XMLReader"], "org.xml.sax.helpers.ParserAdapter", ["java.lang.IllegalStateException", "$.NullPointerException", "java.util.Vector", "org.xml.sax.InputSource", "$.SAXException", "$.SAXNotRecognizedException", "$.SAXNotSupportedException", "$.SAXParseException", "org.xml.sax.helpers.AttributesImpl", "$.NamespaceSupport", "$.ParserFactory"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.nsSupport = null;
\r
5 this.attAdapter = null;
\r
6 this.parsing = false;
\r
7 this.nameParts = null;
\r
10 this.namespaces = true;
\r
11 this.prefixes = false;
\r
13 this.locator = null;
\r
14 this.entityResolver = null;
\r
15 this.dtdHandler = null;
\r
16 this.contentHandler = null;
\r
17 this.errorHandler = null;
\r
18 if (!Clazz.isClassDefined ("org.xml.sax.helpers.ParserAdapter.AttributeListAdapter")) {
\r
19 org.xml.sax.helpers.ParserAdapter.$ParserAdapter$AttributeListAdapter$ ();
\r
21 Clazz.instantialize (this, arguments);
\r
22 }, org.xml.sax.helpers, "ParserAdapter", null, [org.xml.sax.XMLReader, org.xml.sax.DocumentHandler]);
\r
23 Clazz.prepareFields (c$, function () {
\r
24 this.nameParts = new Array (3);
\r
26 Clazz.makeConstructor (c$,
\r
28 var driver = System.getProperty ("org.xml.sax.parser");
\r
30 this.setup (org.xml.sax.helpers.ParserFactory.makeParser ());
\r
32 if (Clazz.exceptionOf (e$$, ClassNotFoundException)) {
\r
35 throw new org.xml.sax.SAXException ("Cannot find SAX1 driver class " + driver, e1);
\r
37 } else if (Clazz.exceptionOf (e$$, IllegalAccessException)) {
\r
40 throw new org.xml.sax.SAXException ("SAX1 driver class " + driver + " found but cannot be loaded", e2);
\r
42 } else if (Clazz.exceptionOf (e$$, InstantiationException)) {
\r
45 throw new org.xml.sax.SAXException ("SAX1 driver class " + driver + " loaded but cannot be instantiated", e3);
\r
47 } else if (Clazz.exceptionOf (e$$, ClassCastException)) {
\r
50 throw new org.xml.sax.SAXException ("SAX1 driver class " + driver + " does not implement org.xml.sax.Parser");
\r
52 } else if (Clazz.exceptionOf (e$$, NullPointerException)) {
\r
55 throw new org.xml.sax.SAXException ("System property org.xml.sax.parser not specified");
\r
62 Clazz.makeConstructor (c$,
\r
64 this.setup (parser);
\r
65 }, "org.xml.sax.Parser");
\r
66 Clazz.defineMethod (c$, "setup",
\r
68 if (parser == null) {
\r
69 throw new NullPointerException ("Parser argument must not be null");
\r
70 }this.parser = parser;
\r
71 this.atts = new org.xml.sax.helpers.AttributesImpl ();
\r
72 this.nsSupport = new org.xml.sax.helpers.NamespaceSupport ();
\r
73 this.attAdapter = Clazz.innerTypeInstance (org.xml.sax.helpers.ParserAdapter.AttributeListAdapter, this, null);
\r
74 }, "org.xml.sax.Parser");
\r
75 Clazz.overrideMethod (c$, "setFeature",
\r
76 function (name, value) {
\r
77 if (name.equals ("http://xml.org/sax/features/namespaces")) {
\r
78 this.checkNotParsing ("feature", name);
\r
79 this.namespaces = value;
\r
80 if (!this.namespaces && !this.prefixes) {
\r
81 this.prefixes = true;
\r
82 }} else if (name.equals ("http://xml.org/sax/features/namespace-prefixes")) {
\r
83 this.checkNotParsing ("feature", name);
\r
84 this.prefixes = value;
\r
85 if (!this.prefixes && !this.namespaces) {
\r
86 this.namespaces = true;
\r
87 }} else if (name.equals ("http://xml.org/sax/features/xmlns-uris")) {
\r
88 this.checkNotParsing ("feature", name);
\r
91 throw new org.xml.sax.SAXNotRecognizedException ("Feature: " + name);
\r
93 Clazz.overrideMethod (c$, "getFeature",
\r
95 if (name.equals ("http://xml.org/sax/features/namespaces")) {
\r
96 return this.namespaces;
\r
97 } else if (name.equals ("http://xml.org/sax/features/namespace-prefixes")) {
\r
98 return this.prefixes;
\r
99 } else if (name.equals ("http://xml.org/sax/features/xmlns-uris")) {
\r
102 throw new org.xml.sax.SAXNotRecognizedException ("Feature: " + name);
\r
104 Clazz.overrideMethod (c$, "setProperty",
\r
105 function (name, value) {
\r
106 throw new org.xml.sax.SAXNotRecognizedException ("Property: " + name);
\r
108 Clazz.overrideMethod (c$, "getProperty",
\r
110 throw new org.xml.sax.SAXNotRecognizedException ("Property: " + name);
\r
112 Clazz.overrideMethod (c$, "setEntityResolver",
\r
113 function (resolver) {
\r
114 this.entityResolver = resolver;
\r
115 }, "org.xml.sax.EntityResolver");
\r
116 Clazz.overrideMethod (c$, "getEntityResolver",
\r
118 return this.entityResolver;
\r
120 Clazz.overrideMethod (c$, "setDTDHandler",
\r
121 function (handler) {
\r
122 this.dtdHandler = handler;
\r
123 }, "org.xml.sax.DTDHandler");
\r
124 Clazz.overrideMethod (c$, "getDTDHandler",
\r
126 return this.dtdHandler;
\r
128 Clazz.overrideMethod (c$, "setContentHandler",
\r
129 function (handler) {
\r
130 this.contentHandler = handler;
\r
131 }, "org.xml.sax.ContentHandler");
\r
132 Clazz.overrideMethod (c$, "getContentHandler",
\r
134 return this.contentHandler;
\r
136 Clazz.overrideMethod (c$, "setErrorHandler",
\r
137 function (handler) {
\r
138 this.errorHandler = handler;
\r
139 }, "org.xml.sax.ErrorHandler");
\r
140 Clazz.overrideMethod (c$, "getErrorHandler",
\r
142 return this.errorHandler;
\r
144 Clazz.defineMethod (c$, "parse",
\r
145 function (systemId) {
\r
146 this.parse ( new org.xml.sax.InputSource (systemId));
\r
148 Clazz.defineMethod (c$, "parse",
\r
150 if (this.parsing) {
\r
151 throw new org.xml.sax.SAXException ("Parser is already in use");
\r
152 }this.setupParser ();
\r
153 this.parsing = true;
\r
155 this.parser.parse (input);
\r
157 this.parsing = false;
\r
159 this.parsing = false;
\r
160 }, "org.xml.sax.InputSource");
\r
161 Clazz.overrideMethod (c$, "setDocumentLocator",
\r
162 function (locator) {
\r
163 this.locator = locator;
\r
164 if (this.contentHandler != null) {
\r
165 this.contentHandler.setDocumentLocator (locator);
\r
166 }}, "org.xml.sax.Locator");
\r
167 Clazz.overrideMethod (c$, "startDocument",
\r
169 if (this.contentHandler != null) {
\r
170 this.contentHandler.startDocument ();
\r
172 Clazz.overrideMethod (c$, "endDocument",
\r
174 if (this.contentHandler != null) {
\r
175 this.contentHandler.endDocument ();
\r
177 Clazz.overrideMethod (c$, "startElement",
\r
178 function (qName, qAtts) {
\r
179 var exceptions = null;
\r
180 if (!this.namespaces) {
\r
181 if (this.contentHandler != null) {
\r
182 this.attAdapter.setAttributeList (qAtts);
\r
183 this.contentHandler.startElement ("", "", qName.intern (), this.attAdapter);
\r
185 }this.nsSupport.pushContext ();
\r
186 var length = qAtts.getLength ();
\r
187 for (var i = 0; i < length; i++) {
\r
188 var attQName = qAtts.getName (i);
\r
189 if (!attQName.startsWith ("xmlns")) continue;
\r
191 var n = attQName.indexOf (':');
\r
192 if (n == -1 && attQName.length == 5) {
\r
194 } else if (n != 5) {
\r
196 } else prefix = attQName.substring (n + 1);
\r
197 var value = qAtts.getValue (i);
\r
198 if (!this.nsSupport.declarePrefix (prefix, value)) {
\r
199 this.reportError ("Illegal Namespace prefix: " + prefix);
\r
201 }if (this.contentHandler != null) this.contentHandler.startPrefixMapping (prefix, value);
\r
203 this.atts.clear ();
\r
204 for (var i = 0; i < length; i++) {
\r
205 var attQName = qAtts.getName (i);
\r
206 var type = qAtts.getType (i);
\r
207 var value = qAtts.getValue (i);
\r
208 if (attQName.startsWith ("xmlns")) {
\r
210 var n = attQName.indexOf (':');
\r
211 if (n == -1 && attQName.length == 5) {
\r
213 } else if (n != 5) {
\r
216 prefix = attQName.substring (6);
\r
217 }if (prefix != null) {
\r
218 if (this.prefixes) {
\r
219 if (this.uris) this.atts.addAttribute (org.xml.sax.helpers.NamespaceSupport.XMLNS, prefix, attQName.intern (), type, value);
\r
220 else this.atts.addAttribute ("", "", attQName.intern (), type, value);
\r
223 var attName = this.processName (attQName, true, true);
\r
224 this.atts.addAttribute (attName[0], attName[1], attName[2], type, value);
\r
226 if (Clazz.exceptionOf (e, org.xml.sax.SAXException)) {
\r
227 if (exceptions == null) exceptions = new java.util.Vector ();
\r
228 exceptions.addElement (e);
\r
229 this.atts.addAttribute ("", attQName, attQName, type, value);
\r
235 if (exceptions != null && this.errorHandler != null) {
\r
236 for (var i = 0; i < exceptions.size (); i++) this.errorHandler.error ((exceptions.elementAt (i)));
\r
238 }if (this.contentHandler != null) {
\r
239 var name = this.processName (qName, false, false);
\r
240 this.contentHandler.startElement (name[0], name[1], name[2], this.atts);
\r
241 }}, "~S,org.xml.sax.AttributeList");
\r
242 Clazz.overrideMethod (c$, "endElement",
\r
244 if (!this.namespaces) {
\r
245 if (this.contentHandler != null) {
\r
246 this.contentHandler.endElement ("", "", qName.intern ());
\r
248 }var names = this.processName (qName, false, false);
\r
249 if (this.contentHandler != null) {
\r
250 this.contentHandler.endElement (names[0], names[1], names[2]);
\r
251 var prefixes = this.nsSupport.getDeclaredPrefixes ();
\r
252 while (prefixes.hasMoreElements ()) {
\r
253 var prefix = prefixes.nextElement ();
\r
254 this.contentHandler.endPrefixMapping (prefix);
\r
256 }this.nsSupport.popContext ();
\r
258 Clazz.overrideMethod (c$, "characters",
\r
259 function (ch, start, length) {
\r
260 if (this.contentHandler != null) {
\r
261 this.contentHandler.characters (ch, start, length);
\r
263 Clazz.overrideMethod (c$, "ignorableWhitespace",
\r
264 function (ch, start, length) {
\r
265 if (this.contentHandler != null) {
\r
266 this.contentHandler.ignorableWhitespace (ch, start, length);
\r
268 Clazz.overrideMethod (c$, "processingInstruction",
\r
269 function (target, data) {
\r
270 if (this.contentHandler != null) {
\r
271 this.contentHandler.processingInstruction (target, data);
\r
273 Clazz.defineMethod (c$, "setupParser",
\r
275 if (!this.prefixes && !this.namespaces) throw new IllegalStateException ();
\r
276 this.nsSupport.reset ();
\r
277 if (this.uris) this.nsSupport.setNamespaceDeclUris (true);
\r
278 if (this.entityResolver != null) {
\r
279 this.parser.setEntityResolver (this.entityResolver);
\r
280 }if (this.dtdHandler != null) {
\r
281 this.parser.setDTDHandler (this.dtdHandler);
\r
282 }if (this.errorHandler != null) {
\r
283 this.parser.setErrorHandler (this.errorHandler);
\r
284 }this.parser.setDocumentHandler (this);
\r
285 this.locator = null;
\r
287 Clazz.defineMethod (c$, "processName",
\r
288 function (qName, isAttribute, useException) {
\r
289 var parts = this.nsSupport.processName (qName, this.nameParts, isAttribute);
\r
290 if (parts == null) {
\r
291 if (useException) throw this.makeException ("Undeclared prefix: " + qName);
\r
292 this.reportError ("Undeclared prefix: " + qName);
\r
293 parts = new Array (3);
\r
294 parts[0] = parts[1] = "";
\r
295 parts[2] = qName.intern ();
\r
298 Clazz.defineMethod (c$, "reportError",
\r
299 function (message) {
\r
300 if (this.errorHandler != null) this.errorHandler.error (this.makeException (message));
\r
302 Clazz.defineMethod (c$, "makeException",
\r
303 function (message) {
\r
304 if (this.locator != null) {
\r
305 return new org.xml.sax.SAXParseException (message, this.locator);
\r
307 return new org.xml.sax.SAXParseException (message, null, null, -1, -1);
\r
309 Clazz.defineMethod (c$, "checkNotParsing",
\r
310 function (type, name) {
\r
311 if (this.parsing) {
\r
312 throw new org.xml.sax.SAXNotSupportedException ("Cannot change " + type + ' ' + name + " while parsing");
\r
314 c$.$ParserAdapter$AttributeListAdapter$ = function () {
\r
315 Clazz.pu$h(self.c$);
\r
316 c$ = Clazz.decorateAsClass (function () {
\r
317 Clazz.prepareCallback (this, arguments);
\r
319 Clazz.instantialize (this, arguments);
\r
320 }, org.xml.sax.helpers.ParserAdapter, "AttributeListAdapter", null, org.xml.sax.Attributes);
\r
321 Clazz.makeConstructor (c$,
\r
324 Clazz.defineMethod (c$, "setAttributeList",
\r
327 }, "org.xml.sax.AttributeList");
\r
328 Clazz.overrideMethod (c$, "getLength",
\r
330 return this.qAtts.getLength ();
\r
332 Clazz.overrideMethod (c$, "getURI",
\r
336 Clazz.overrideMethod (c$, "getLocalName",
\r
340 Clazz.overrideMethod (c$, "getQName",
\r
342 return this.qAtts.getName (a).intern ();
\r
344 Clazz.defineMethod (c$, "getType",
\r
346 return this.qAtts.getType (a).intern ();
\r
348 Clazz.defineMethod (c$, "getValue",
\r
350 return this.qAtts.getValue (a);
\r
352 Clazz.defineMethod (c$, "getIndex",
\r
356 Clazz.defineMethod (c$, "getIndex",
\r
358 var b = this.b$["org.xml.sax.helpers.ParserAdapter"].atts.getLength ();
\r
359 for (var c = 0; c < b; c++) {
\r
360 if (this.qAtts.getName (c).equals (a)) {
\r
365 Clazz.defineMethod (c$, "getType",
\r
369 Clazz.defineMethod (c$, "getType",
\r
371 return this.qAtts.getType (a).intern ();
\r
373 Clazz.defineMethod (c$, "getValue",
\r
377 Clazz.defineMethod (c$, "getValue",
\r
379 return this.qAtts.getValue (a);
\r
383 Clazz.defineStatics (c$,
\r
384 "FEATURES", "http://xml.org/sax/features/");
\r
385 c$.NAMESPACES = c$.prototype.NAMESPACES = "http://xml.org/sax/features/namespaces";
\r
386 c$.NAMESPACE_PREFIXES = c$.prototype.NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
\r
387 c$.XMLNS_URIs = c$.prototype.XMLNS_URIs = "http://xml.org/sax/features/xmlns-uris";
\r