KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xml > serializer > ToTextSAXHandler


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: ToTextSAXHandler.java,v 1.5 2004/02/17 04:18:18 minchau Exp $
18  */

19 package org.apache.xml.serializer;
20
21 import java.io.IOException JavaDoc;
22 import java.io.OutputStream JavaDoc;
23 import java.io.Writer JavaDoc;
24 import java.util.Properties JavaDoc;
25
26 import org.w3c.dom.Node JavaDoc;
27 import org.xml.sax.Attributes JavaDoc;
28 import org.xml.sax.ContentHandler JavaDoc;
29 import org.xml.sax.Locator JavaDoc;
30 import org.xml.sax.SAXException JavaDoc;
31 import org.xml.sax.ext.LexicalHandler JavaDoc;
32
33 /**
34  * @author minchau
35  *
36  * To change this generated comment edit the template variable "typecomment":
37  * Window>Preferences>Java>Templates.
38  * To enable and disable the creation of type comments go to
39  * Window>Preferences>Java>Code Generation.
40  * @author Santiago Pericas-Geertsen
41  */

42 public class ToTextSAXHandler extends ToSAXHandler
43 {
44     /**
45      * From XSLTC
46      * @see org.apache.xml.serializer.ExtendedContentHandler#endElement(String)
47      */

48     public void endElement(String JavaDoc elemName) throws SAXException JavaDoc
49     {
50         if (m_tracer != null)
51             super.fireEndElem(elemName);
52     }
53
54     /**
55      * @see org.xml.sax.ContentHandler#endElement(String, String, String)
56      */

57     public void endElement(String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2)
58         throws SAXException JavaDoc
59     {
60         if (m_tracer != null)
61             super.fireEndElem(arg2);
62     }
63
64     public ToTextSAXHandler(ContentHandler JavaDoc hdlr, LexicalHandler JavaDoc lex, String JavaDoc encoding)
65     {
66         super(hdlr, lex, encoding);
67     }
68     
69         /**
70      * From XSLTC
71      */

72     public ToTextSAXHandler(ContentHandler JavaDoc handler, String JavaDoc encoding)
73     {
74         super(handler,encoding);
75     }
76
77     public void comment(char ch[], int start, int length)
78         throws org.xml.sax.SAXException JavaDoc
79     {
80         if (m_tracer != null)
81             super.fireCommentEvent(ch, start, length);
82     }
83
84     public void comment(String JavaDoc data) throws org.xml.sax.SAXException JavaDoc
85     {
86         final int length = data.length();
87         if (length > m_charsBuff.length)
88         {
89             m_charsBuff = new char[length*2 + 1];
90         }
91         data.getChars(0, length, m_charsBuff, 0);
92         comment(m_charsBuff, 0, length);
93     }
94
95     /**
96      * @see org.apache.xml.serializer.Serializer#getOutputFormat()
97      */

98     public Properties JavaDoc getOutputFormat()
99     {
100         return null;
101     }
102
103     /**
104      * @see org.apache.xml.serializer.Serializer#getOutputStream()
105      */

106     public OutputStream JavaDoc getOutputStream()
107     {
108         return null;
109     }
110
111     /**
112      * @see org.apache.xml.serializer.Serializer#getWriter()
113      */

114     public Writer JavaDoc getWriter()
115     {
116         return null;
117     }
118
119     /**
120      * Does nothing because
121      * the indent attribute is ignored for text output.
122      *
123      */

124     public void indent(int n) throws SAXException JavaDoc
125     {
126     }
127
128     /**
129      * @see org.apache.xml.serializer.Serializer#reset()
130      */

131     public boolean reset()
132     {
133         return false;
134     }
135
136     /**
137      * @see org.apache.xml.serializer.DOMSerializer#serialize(Node)
138      */

139     public void serialize(Node JavaDoc node) throws IOException JavaDoc
140     {
141     }
142
143     /**
144      * @see org.apache.xml.serializer.SerializationHandler#setEscaping(boolean)
145      */

146     public boolean setEscaping(boolean escape)
147     {
148         return false;
149     }
150
151     /**
152      * @see org.apache.xml.serializer.SerializationHandler#setIndent(boolean)
153      */

154     public void setIndent(boolean indent)
155     {
156     }
157
158     /**
159      * @see org.apache.xml.serializer.Serializer#setOutputFormat(Properties)
160      */

161     public void setOutputFormat(Properties JavaDoc format)
162     {
163     }
164
165     /**
166      * @see org.apache.xml.serializer.Serializer#setOutputStream(OutputStream)
167      */

168     public void setOutputStream(OutputStream JavaDoc output)
169     {
170     }
171
172     /**
173      * @see org.apache.xml.serializer.Serializer#setWriter(Writer)
174      */

175     public void setWriter(Writer JavaDoc writer)
176     {
177     }
178
179     /**
180      * @see org.apache.xml.serializer.ExtendedContentHandler#addAttribute(String, String, String, String, String)
181      */

182     public void addAttribute(
183         String JavaDoc uri,
184         String JavaDoc localName,
185         String JavaDoc rawName,
186         String JavaDoc type,
187         String JavaDoc value)
188     {
189     }
190
191     /**
192      * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
193      */

194     public void attributeDecl(
195         String JavaDoc arg0,
196         String JavaDoc arg1,
197         String JavaDoc arg2,
198         String JavaDoc arg3,
199         String JavaDoc arg4)
200         throws SAXException JavaDoc
201     {
202     }
203
204     /**
205      * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
206      */

207     public void elementDecl(String JavaDoc arg0, String JavaDoc arg1) throws SAXException JavaDoc
208     {
209     }
210
211     /**
212      * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
213      */

214     public void externalEntityDecl(String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2)
215         throws SAXException JavaDoc
216     {
217     }
218
219     /**
220      * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
221      */

222     public void internalEntityDecl(String JavaDoc arg0, String JavaDoc arg1)
223         throws SAXException JavaDoc
224     {
225     }
226
227     /**
228      * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
229      */

230     public void endPrefixMapping(String JavaDoc arg0) throws SAXException JavaDoc
231     {
232     }
233
234     /**
235      * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
236      */

237     public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
238         throws SAXException JavaDoc
239     {
240     }
241
242     /**
243      * From XSLTC
244      * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
245      */

246     public void processingInstruction(String JavaDoc arg0, String JavaDoc arg1)
247         throws SAXException JavaDoc
248     {
249         if (m_tracer != null)
250             super.fireEscapingEvent(arg0, arg1);
251     }
252
253     /**
254      * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
255      */

256     public void setDocumentLocator(Locator JavaDoc arg0)
257     {
258     }
259
260     /**
261      * @see org.xml.sax.ContentHandler#skippedEntity(String)
262      */

263     public void skippedEntity(String JavaDoc arg0) throws SAXException JavaDoc
264     {
265     }
266
267     /**
268      * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
269      */

270     public void startElement(
271         String JavaDoc arg0,
272         String JavaDoc arg1,
273         String JavaDoc arg2,
274         Attributes JavaDoc arg3)
275         throws SAXException JavaDoc
276     {
277         flushPending();
278         super.startElement(arg0, arg1, arg2, arg3);
279     }
280
281     /**
282      * @see org.xml.sax.ext.LexicalHandler#endCDATA()
283      */

284     public void endCDATA() throws SAXException JavaDoc
285     {
286     }
287
288     /**
289      * @see org.xml.sax.ext.LexicalHandler#endDTD()
290      */

291     public void endDTD() throws SAXException JavaDoc
292     {
293     }
294
295     /**
296      * @see org.xml.sax.ext.LexicalHandler#startCDATA()
297      */

298     public void startCDATA() throws SAXException JavaDoc
299     {
300     }
301
302
303     /**
304      * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
305      */

306     public void startEntity(String JavaDoc arg0) throws SAXException JavaDoc
307     {
308     }
309
310
311     /**
312      * From XSLTC
313      * @see org.apache.xml.serializer.ExtendedContentHandler#startElement(String)
314      */

315     public void startElement(
316     String JavaDoc elementNamespaceURI,
317     String JavaDoc elementLocalName,
318     String JavaDoc elementName) throws SAXException JavaDoc
319     {
320         super.startElement(elementNamespaceURI, elementLocalName, elementName);
321     }
322     
323     public void startElement(
324     String JavaDoc elementName) throws SAXException JavaDoc
325     {
326         super.startElement(elementName);
327     }
328     
329
330     /**
331      * From XSLTC
332      * @see org.xml.sax.ContentHandler#endDocument()
333      */

334     public void endDocument() throws SAXException JavaDoc {
335         
336         flushPending();
337         m_saxHandler.endDocument();
338         
339         if (m_tracer != null)
340             super.fireEndDoc();
341     }
342  
343     /**
344      *
345      * @see org.apache.xml.serializer.ExtendedContentHandler#characters(String)
346      */

347     public void characters(String JavaDoc characters)
348     throws SAXException JavaDoc
349     {
350         final int length = characters.length();
351         if (length > m_charsBuff.length)
352         {
353             m_charsBuff = new char[length*2 + 1];
354         }
355         characters.getChars(0, length, m_charsBuff, 0);
356    
357         m_saxHandler.characters(m_charsBuff, 0, length);
358     
359     }
360     /**
361      * @see org.xml.sax.ContentHandler#characters(char[], int, int)
362      */

363     public void characters(char[] characters, int offset, int length)
364     throws SAXException JavaDoc
365     {
366     
367         m_saxHandler.characters(characters, offset, length);
368
369         // time to fire off characters event
370
if (m_tracer != null)
371             super.fireCharEvent(characters, offset, length);
372     }
373
374     /**
375      * From XSLTC
376      */

377     public void addAttribute(String JavaDoc name, String JavaDoc value)
378     {
379         // do nothing
380
}
381
382
383     public boolean startPrefixMapping(
384         String JavaDoc prefix,
385         String JavaDoc uri,
386         boolean shouldFlush)
387         throws SAXException JavaDoc
388     {
389         // no namespace support for HTML
390
return false;
391     }
392
393
394     public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri)
395         throws org.xml.sax.SAXException JavaDoc
396     {
397         // no namespace support for HTML
398
}
399
400
401     public void namespaceAfterStartElement(
402         final String JavaDoc prefix,
403         final String JavaDoc uri)
404         throws SAXException JavaDoc
405     {
406         // no namespace support for HTML
407
}
408
409 }
410
Popular Tags