1 Clazz.declarePackage ("org.xml.sax.demo");
2 Clazz.load (["org.xml.sax.DTDHandler", "$.DocumentHandler", "$.EntityResolver", "$.ErrorHandler"], "org.xml.sax.demo.DemoHandler", null, function () {
3 c$ = Clazz.declareType (org.xml.sax.demo, "DemoHandler", null, [org.xml.sax.EntityResolver, org.xml.sax.DTDHandler, org.xml.sax.DocumentHandler, org.xml.sax.ErrorHandler]);
4 Clazz.overrideMethod (c$, "resolveEntity",
5 function (publicId, systemId) {
6 System.out.print ("Resolve entity:");
7 if (publicId != null) {
8 System.out.print (" publicId=\"" + publicId + '"');
9 }System.out.println (" systemId=\"" + systemId + '"');
12 Clazz.overrideMethod (c$, "notationDecl",
13 function (name, publicId, systemId) {
14 System.out.print ("Notation declaration: " + name);
15 if (publicId != null) {
16 System.out.print (" publicId=\"" + publicId + '"');
17 }if (systemId != null) {
18 System.out.print (" systemId=\"" + systemId + '"');
19 }System.out.print ('\n');
21 Clazz.overrideMethod (c$, "unparsedEntityDecl",
22 function (name, publicId, systemId, notationName) {
23 System.out.print ("Unparsed Entity Declaration: " + name);
24 if (publicId != null) {
25 System.out.print (" publicId=\"" + publicId + '"');
26 }if (systemId != null) {
27 System.out.print (" systemId=\"" + systemId + '"');
28 }System.out.println (" notationName=\"" + notationName + '"');
30 Clazz.overrideMethod (c$, "setDocumentLocator",
32 System.out.println ("Document locator supplied.");
33 }, "org.xml.sax.Locator");
34 Clazz.overrideMethod (c$, "startDocument",
36 System.out.println ("Start document");
38 Clazz.overrideMethod (c$, "endDocument",
40 System.out.println ("End document");
42 Clazz.overrideMethod (c$, "startElement",
43 function (name, attributes) {
44 System.out.println ("Start element: " + name);
45 for (var i = 0; i < attributes.getLength (); i++) {
46 System.out.println (" Attribute: " + attributes.getName (i) + ' ' + attributes.getType (i) + " \"" + attributes.getValue (i) + '"');
48 }, "~S,org.xml.sax.AttributeList");
49 Clazz.overrideMethod (c$, "endElement",
51 System.out.println ("End element: " + name);
53 Clazz.overrideMethod (c$, "characters",
54 function (ch, start, length) {
55 System.out.print ("Characters: ");
56 org.xml.sax.demo.DemoHandler.display (ch, start, length);
58 Clazz.overrideMethod (c$, "ignorableWhitespace",
59 function (ch, start, length) {
60 System.out.print ("Ignorable Whitespace: ");
61 org.xml.sax.demo.DemoHandler.display (ch, start, length);
63 Clazz.overrideMethod (c$, "processingInstruction",
64 function (target, data) {
65 System.out.println ("Processing instruction: " + target + ' ' + data);
67 Clazz.overrideMethod (c$, "warning",
68 function (exception) {
69 System.out.println ("Warning: " + exception.getMessage () + " (" + exception.getSystemId () + ':' + exception.getLineNumber () + ',' + exception.getColumnNumber () + ')');
70 }, "org.xml.sax.SAXParseException");
71 Clazz.overrideMethod (c$, "error",
72 function (exception) {
73 System.out.println ("Recoverable Error: " + exception.getMessage () + " (" + exception.getSystemId () + ':' + exception.getLineNumber () + ',' + exception.getColumnNumber () + ')');
74 }, "org.xml.sax.SAXParseException");
75 Clazz.overrideMethod (c$, "fatalError",
76 function (exception) {
77 System.out.println ("Fatal Error: " + exception.getMessage () + " (" + exception.getSystemId () + ':' + exception.getLineNumber () + ',' + exception.getColumnNumber () + ')');
78 }, "org.xml.sax.SAXParseException");
79 c$.display = Clazz.defineMethod (c$, "display",
80 function (ch, start, length) {
81 for (var i = start; i < start + length; i++) {
84 System.out.print ("\\n");
87 System.out.print ("\\t");
90 System.out.print (ch[i]);
94 System.out.print ("\n");