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