KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > kawa > sax > ConsumeSAXHandler


1 // Copyright (c) 2002 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.kawa.sax;
5 import gnu.lists.*;
6 import gnu.xml.*;
7 import org.xml.sax.*;
8 import gnu.mapping.Symbol;
9
10 /** Forward SAX1 or SAX2 events to a Consumer.
11  */

12
13 public class ConsumeSAXHandler implements DocumentHandler, ContentHandler
14 {
15   Consumer out;
16
17   public void setDocumentLocator(Locator locator)
18   {
19     // FIXME
20
}
21
22   public ConsumeSAXHandler(Consumer out)
23   {
24     this.out = out;
25   }
26
27   public void startDocument()
28   {
29     out.beginDocument();
30   }
31
32   public void endDocument()
33   {
34     out.endDocument();
35   }
36
37   public void startElement (String JavaDoc namespaceURI, String JavaDoc localName,
38                 String JavaDoc qName, Attributes atts)
39         throws SAXException
40   {
41     out.beginGroup(Symbol.make(namespaceURI, localName));
42     int numAttributes = atts.getLength();
43     for (int i = 0; i < numAttributes; i++)
44       {
45     out.beginAttribute(Symbol.make(atts.getURI(i), atts.getLocalName(i)));
46     out.write(atts.getValue(i));
47     out.endAttribute();
48       }
49   }
50
51   public void endElement (String JavaDoc namespaceURI, String JavaDoc localName,
52               String JavaDoc qName)
53     throws SAXException
54   {
55     out.endGroup();
56   }
57
58   public void startElement (String JavaDoc name, AttributeList atts)
59     throws SAXException
60   {
61     name = name.intern(); // ???
62
out.beginGroup(name); // FIXME
63
int attrLength = atts.getLength();
64     for (int i = 0; i < attrLength; i++)
65       {
66     name = atts.getName(i);
67     name = name.intern(); // ?
68
String JavaDoc type = atts.getType(i);
69     String JavaDoc value = atts.getValue(i);
70     out.beginAttribute(name); // FIXME
71
out.write(value);
72     out.endAttribute();
73       }
74   }
75
76   public void endElement (String JavaDoc name)
77     throws SAXException
78   {
79     out.endGroup();
80   }
81
82   public void characters (char ch[], int start, int length)
83     throws SAXException
84   {
85     out.write(ch, start, length);
86   }
87
88   public void ignorableWhitespace (char ch[], int start, int length)
89     throws SAXException
90   {
91     // FIXME
92
out.write(ch, start, length);
93   }
94
95   public void processingInstruction(String JavaDoc target, String JavaDoc data)
96   {
97     // FIXME
98
}
99
100   public void startPrefixMapping (String JavaDoc prefix, String JavaDoc uri)
101   {
102     // FIXME
103
}
104
105   public void endPrefixMapping (String JavaDoc prefix)
106   {
107     // FIXME
108
}
109
110   public void skippedEntity (String JavaDoc name)
111   {
112     // FIXME
113
}
114 }
115
Popular Tags