1 package net.sf.tomp.xtcl.filter;
2
3 import org.xml.sax.Attributes;
4 import org.xml.sax.ContentHandler;
5 import org.xml.sax.Locator;
6 import org.xml.sax.SAXException;
7
8 /***
9 * DOCUMENT ME!
10 *
11 * @author tomp
12 */
13 public class TeeFilterImpl extends XTFilterImpl implements TeeFilter {
14 /*** DOCUMENT ME! */
15 protected ContentHandler contentHandler2 = null;
16
17
18
19
20
21 /***
22 * Construct an empty XML filter, with no parent.
23 * <p>
24 * This filter will have no parent: you must assign a parent before you
25 * start a parse or do any configuration with setFeature or setProperty.
26 * </p>
27 *
28 * @param handler DOCUMENT ME!
29 * @throws NullPointerException DOCUMENT ME!
30 * @see org.xml.sax.XMLReader#setFeature
31 * @see org.xml.sax.XMLReader#setProperty
32 */
33
34
35
36
37
38 /***
39 * Construct an XML filter with the specified parent.
40 *
41 * @param handler DOCUMENT ME!
42 * @throws NullPointerException DOCUMENT ME!
43 * @see #setParent
44 * @see #getParent
45 */
46
47
48
49
50
51 /***
52 * Set the secondary content event handler.
53 *
54 * @param handler The new content handler.
55 * @exception NullPointerException If the handler is null.
56 * @see org.xml.sax.XMLReader#setContentHandler
57 */
58 public void setContentHandler2(ContentHandler handler) {
59 if (handler == null) {
60 throw new NullPointerException("Null content handler");
61 } else {
62 contentHandler2 = handler;
63
64
65 }
66 }
67
68 /***
69 * Get the content event handler.
70 *
71 * @return The current content handler, or null if none was set.
72 * @see org.xml.sax.XMLReader#getContentHandler
73 */
74 public ContentHandler getContentHandler2() {
75 return contentHandler2;
76 }
77
78
79
80
81
82 /***
83 * Filter a new document locator event.
84 *
85 * @param locator The document locator.
86 * @see org.xml.sax.ContentHandler#setDocumentLocator
87 */
88 public void setDocumentLocator(Locator locator) {
89 this.locator = locator;
90
91 if (contentHandler != null) {
92 contentHandler.setDocumentLocator(locator);
93 }
94
95 if (contentHandler2 != null) {
96 contentHandler2.setDocumentLocator(locator);
97 }
98 }
99
100 /***
101 * Filter a start document event.
102 *
103 * @exception SAXException The client may throw an exception during
104 * processing.
105 * @see org.xml.sax.ContentHandler#startDocument
106 */
107 public void startDocument() throws SAXException {
108 if (contentHandler != null) {
109 contentHandler.startDocument();
110 }
111
112 if (contentHandler2 != null) {
113
114
115 contentHandler2.startDocument();
116
117
118
119 }
120 }
121
122 /***
123 * Filter an end document event.
124 *
125 * @exception SAXException The client may throw an exception during
126 * processing.
127 * @see org.xml.sax.ContentHandler#endDocument
128 */
129 public void endDocument() throws SAXException {
130 if (contentHandler != null) {
131 contentHandler.endDocument();
132 }
133
134 if (contentHandler2 != null) {
135 contentHandler2.endDocument();
136 }
137 }
138
139 /***
140 * Filter a start Namespace prefix mapping event.
141 *
142 * @param prefix The Namespace prefix.
143 * @param uri The Namespace URI.
144 * @exception SAXException The client may throw an exception during
145 * processing.
146 * @see org.xml.sax.ContentHandler#startPrefixMapping
147 */
148 public void startPrefixMapping(String prefix, String uri)
149 throws SAXException {
150 if (contentHandler != null) {
151 contentHandler.startPrefixMapping(prefix, uri);
152 }
153
154 if (contentHandler2 != null) {
155 contentHandler2.startPrefixMapping(prefix, uri);
156 }
157 }
158
159 /***
160 * Filter an end Namespace prefix mapping event.
161 *
162 * @param prefix The Namespace prefix.
163 * @exception SAXException The client may throw an exception during
164 * processing.
165 * @see org.xml.sax.ContentHandler#endPrefixMapping
166 */
167 public void endPrefixMapping(String prefix) throws SAXException {
168 if (contentHandler != null) {
169 contentHandler.endPrefixMapping(prefix);
170 }
171
172 if (contentHandler2 != null) {
173 contentHandler2.endPrefixMapping(prefix);
174 }
175 }
176
177 /***
178 * Filter a start element event.
179 *
180 * @param uri The element's Namespace URI, or the empty string.
181 * @param localName The element's local name, or the empty string.
182 * @param qName The element's qualified (prefixed) name, or the empty
183 * string.
184 * @param atts The element's attributes.
185 * @exception SAXException The client may throw an exception during
186 * processing.
187 * @see org.xml.sax.ContentHandler#startElement
188 */
189 public void startElement(String uri, String localName, String qName,
190 Attributes atts) throws SAXException {
191 if (contentHandler != null) {
192 contentHandler.startElement(uri, localName, qName, atts);
193 }
194
195 if (contentHandler2 != null) {
196 contentHandler2.startElement(uri, localName, qName, atts);
197 }
198 }
199
200 /***
201 * Filter an end element event.
202 *
203 * @param uri The element's Namespace URI, or the empty string.
204 * @param localName The element's local name, or the empty string.
205 * @param qName The element's qualified (prefixed) name, or the empty
206 * string.
207 * @exception SAXException The client may throw an exception during
208 * processing.
209 * @see org.xml.sax.ContentHandler#endElement
210 */
211 public void endElement(String uri, String localName, String qName)
212 throws SAXException {
213 if (contentHandler != null) {
214 contentHandler.endElement(uri, localName, qName);
215 }
216
217 if (contentHandler2 != null) {
218 contentHandler2.endElement(uri, localName, qName);
219 }
220 }
221
222 /***
223 * Filter a character data event.
224 *
225 * @param ch An array of characters.
226 * @param start The starting position in the array.
227 * @param length The number of characters to use from the array.
228 * @exception SAXException The client may throw an exception during
229 * processing.
230 * @see org.xml.sax.ContentHandler#characters
231 */
232 public void characters(char[] ch, int start, int length)
233 throws SAXException {
234 if (contentHandler != null) {
235 contentHandler.characters(ch, start, length);
236 }
237
238 if (contentHandler2 != null) {
239 contentHandler2.characters(ch, start, length);
240 }
241 }
242
243 /***
244 * Filter an ignorable whitespace event.
245 *
246 * @param ch An array of characters.
247 * @param start The starting position in the array.
248 * @param length The number of characters to use from the array.
249 * @exception SAXException The client may throw an exception during
250 * processing.
251 * @see org.xml.sax.ContentHandler#ignorableWhitespace
252 */
253 public void ignorableWhitespace(char[] ch, int start, int length)
254 throws SAXException {
255 if (contentHandler != null) {
256 contentHandler.ignorableWhitespace(ch, start, length);
257 }
258
259 if (contentHandler2 != null) {
260 contentHandler2.ignorableWhitespace(ch, start, length);
261 }
262 }
263
264 /***
265 * Filter a processing instruction event.
266 *
267 * @param target The processing instruction target.
268 * @param data The text following the target.
269 * @exception SAXException The client may throw an exception during
270 * processing.
271 * @see org.xml.sax.ContentHandler#processingInstruction
272 */
273 public void processingInstruction(String target, String data)
274 throws SAXException {
275 if (contentHandler != null) {
276 contentHandler.processingInstruction(target, data);
277 }
278
279 if (contentHandler2 != null) {
280 contentHandler2.processingInstruction(target, data);
281 }
282 }
283
284 /***
285 * Filter a skipped entity event.
286 *
287 * @param name The name of the skipped entity.
288 * @exception SAXException The client may throw an exception during
289 * processing.
290 * @see org.xml.sax.ContentHandler#skippedEntity
291 */
292 public void skippedEntity(String name) throws SAXException {
293 if (contentHandler != null) {
294 contentHandler.skippedEntity(name);
295 }
296
297 if (contentHandler2 != null) {
298 contentHandler2.skippedEntity(name);
299 }
300 }
301 }
302
303
304
305
306
307
308
309
310
311
312