KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sax > XMLFilterBase


1 /*--
2
3  Copyright (C) 2000 Brett McLaughlin & Jason Hunter.
4  All rights reserved.
5  
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions
8  are met:
9  
10  1. Redistributions of source code must retain the above copyright
11     notice, this list of conditions, and the following disclaimer.
12  
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions, and the disclaimer that follows
15     these conditions in the documentation and/or other materials
16     provided with the distribution.
17
18  3. The name "JDOM" must not be used to endorse or promote products
19     derived from this software without prior written permission. For
20     written permission, please contact license@jdom.org.
21  
22  4. Products derived from this software may not be called "JDOM", nor
23     may "JDOM" appear in their name, without prior written permission
24     from the JDOM Project Management (pm@jdom.org).
25  
26  In addition, we request (but do not require) that you include in the
27  end-user documentation provided with the redistribution and/or in the
28  software itself an acknowledgement equivalent to the following:
29      "This product includes software developed by the
30       JDOM Project (http://www.jdom.org/)."
31  Alternatively, the acknowledgment may be graphical using the logos
32  available at http://www.jdom.org/images/logos.
33
34  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
38  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
41  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
44  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45  SUCH DAMAGE.
46
47  This software consists of voluntary contributions made by many
48  individuals on behalf of the JDOM Project and was originally
49  created by Brett McLaughlin <brett@jdom.org> and
50  Jason Hunter <jhunter@jdom.org>. For more information on the
51  JDOM Project, please see <http://www.jdom.org/>.
52  
53  */

54 package sax;
55
56 import java.io.IOException JavaDoc;
57
58 import org.xml.sax.Attributes JavaDoc;
59 import org.xml.sax.InputSource JavaDoc;
60 import org.xml.sax.SAXException JavaDoc;
61 import org.xml.sax.SAXNotRecognizedException JavaDoc;
62 import org.xml.sax.SAXNotSupportedException JavaDoc;
63 import org.xml.sax.XMLReader JavaDoc;
64 import org.xml.sax.ext.LexicalHandler JavaDoc;
65 import org.xml.sax.helpers.AttributesImpl JavaDoc;
66 import org.xml.sax.helpers.XMLFilterImpl JavaDoc;
67
68 /**
69  * Adds convenience methods and lexical event filtering to base
70  * SAX2 Filter implementation.
71  *
72  * <i>Code and comments adapted from XMLWriter-0.2, written
73  * by David Megginson and released into the public domain,
74  * without warranty.</i>
75  *
76  * <p>The convenience methods are provided so that clients do not have to
77  * create empty attribute lists or provide empty strings as parameters;
78  * for example, the method invocation</p>
79  *
80  * <pre>
81  * w.startElement("foo");
82  * </pre>
83  *
84  * <p>is equivalent to the regular SAX2 ContentHandler method</p>
85  *
86  * <pre>
87  * w.startElement("", "foo", "", new AttributesImpl());
88  * </pre>
89  *
90  * <p>Except that it is more efficient because it does not allocate
91  * a new empty attribute list each time.</p>
92  *
93  * <p>In fact, there is an even simpler convenience method,
94  * <var>dataElement</var>, designed for writing elements that
95  * contain only character data.</p>
96  *
97  * <pre>
98  * w.dataElement("greeting", "Hello, world!");
99  * </pre>
100  *
101  * <p>is equivalent to</p>
102  *
103  * <pre>
104  * w.startElement("greeting");
105  * w.characters("Hello, world!");
106  * w.endElement("greeting");
107  * </pre>
108  *
109  * @see org.xml.sax.helpers.XMLFilterImpl
110  */

111 public class XMLFilterBase extends XMLFilterImpl JavaDoc implements LexicalHandler JavaDoc
112 {
113
114
115     ////////////////////////////////////////////////////////////////////
116
// Constructors.
117
////////////////////////////////////////////////////////////////////
118

119
120     /**
121      * Construct an XML filter with no parent.
122      *
123      * <p>This filter will have no parent: you must assign a parent
124      * before you start a parse or do any configuration with
125      * setFeature or setProperty.</p>
126      *
127      * @see org.xml.sax.XMLReader#setFeature
128      * @see org.xml.sax.XMLReader#setProperty
129      */

130     public XMLFilterBase()
131     {
132     }
133
134
135     /**
136      * Create an XML filter with the specified parent.
137      *
138      * <p>Use the XMLReader provided as the source of events.</p>
139      *
140      * @param xmlreader The parent in the filter chain.
141      */

142     public XMLFilterBase(XMLReader JavaDoc parent)
143     {
144         super(parent);
145     }
146
147
148
149     ////////////////////////////////////////////////////////////////////
150
// Convenience methods.
151
////////////////////////////////////////////////////////////////////
152

153
154     /**
155      * Start a new element without a qname or attributes.
156      *
157      * <p>This method will provide a default empty attribute
158      * list and an empty string for the qualified name. It invokes
159      * {@link #startElement(String, String, String, Attributes)}
160      * directly.</p>
161      *
162      * @param uri The element's Namespace URI.
163      * @param localName The element's local name.
164      * @exception org.xml.sax.SAXException If a filter
165      * further down the chain raises an exception.
166      * @see org.xml.sax.ContentHandler#startElement
167      */

168     public void startElement (String JavaDoc uri, String JavaDoc localName)
169     throws SAXException JavaDoc
170     {
171         startElement(uri, localName, "", EMPTY_ATTS);
172     }
173
174
175     /**
176      * Start a new element without a Namespace URI or qname.
177      *
178      * <p>This method will provide an empty string for the
179      * Namespace URI, and empty string for the qualified name.
180      * It invokes
181      * {@link #startElement(String, String, String, Attributes)}
182      * directly.</p>
183      *
184      * @param localName The element's local name.
185      * @param atts The element's attribute list.
186      * @exception org.xml.sax.SAXException If a filter
187      * further down the chain raises an exception.
188      * @see org.xml.sax.ContentHandler#startElement
189      */

190     public void startElement (String JavaDoc localName, Attributes JavaDoc atts)
191     throws SAXException JavaDoc
192     {
193         startElement("", localName, "", atts);
194     }
195
196
197     /**
198      * Start a new element without a Namespace URI, qname, or attributes.
199      *
200      * <p>This method will provide an empty string for the
201      * Namespace URI, and empty string for the qualified name,
202      * and a default empty attribute list. It invokes
203      * {@link #startElement(String, String, String, Attributes)}
204      * directly.</p>
205      *
206      * @param localName The element's local name.
207      * @exception org.xml.sax.SAXException If a filter
208      * further down the chain raises an exception.
209      * @see org.xml.sax.ContentHandler#startElement
210      */

211     public void startElement (String JavaDoc localName)
212     throws SAXException JavaDoc
213     {
214         startElement("", localName, "", EMPTY_ATTS);
215     }
216
217
218     /**
219      * End an element without a qname.
220      *
221      * <p>This method will supply an empty string for the qName.
222      * It invokes {@link #endElement(String, String, String)}
223      * directly.</p>
224      *
225      * @param uri The element's Namespace URI.
226      * @param localName The element's local name.
227      * @exception org.xml.sax.SAXException If a filter
228      * further down the chain raises an exception.
229      * @see org.xml.sax.ContentHandler#endElement
230      */

231     public void endElement (String JavaDoc uri, String JavaDoc localName)
232     throws SAXException JavaDoc
233     {
234         endElement(uri, localName, "");
235     }
236
237
238     /**
239      * End an element without a Namespace URI or qname.
240      *
241      * <p>This method will supply an empty string for the qName
242      * and an empty string for the Namespace URI.
243      * It invokes {@link #endElement(String, String, String)}
244      * directly.</p>
245      *
246      * @param localName The element's local name.
247      * @exception org.xml.sax.SAXException If a filter
248      * further down the chain raises an exception.
249      * @see org.xml.sax.ContentHandler#endElement
250      */

251     public void endElement (String JavaDoc localName)
252     throws SAXException JavaDoc
253     {
254         endElement("", localName, "");
255     }
256
257
258     /**
259      * Add an empty element.
260      *
261      * Both a {@link #startElement startElement} and an
262      * {@link #endElement endElement} event will be passed on down
263      * the filter chain.
264      *
265      * @param uri The element's Namespace URI, or the empty string
266      * if the element has no Namespace or if Namespace
267      * processing is not being performed.
268      * @param localName The element's local name (without prefix). This
269      * parameter must be provided.
270      * @param qName The element's qualified name (with prefix), or
271      * the empty string if none is available. This parameter
272      * is strictly advisory: the writer may or may not use
273      * the prefix attached.
274      * @param atts The element's attribute list.
275      * @exception org.xml.sax.SAXException If a filter
276      * further down the chain raises an exception.
277      * @see org.xml.sax.ContentHandler#startElement
278      * @see org.xml.sax.ContentHandler#endElement
279      */

280     public void emptyElement (String JavaDoc uri, String JavaDoc localName,
281     String JavaDoc qName, Attributes JavaDoc atts)
282     throws SAXException JavaDoc
283     {
284         startElement(uri, localName, qName, atts);
285         endElement(uri, localName, qName);
286     }
287
288
289      /**
290       * Add an empty element without a qname or attributes.
291       *
292       * <p>This method will supply an empty string for the qname
293       * and an empty attribute list. It invokes
294       * {@link #emptyElement(String, String, String, Attributes)}
295       * directly.</p>
296       *
297       * @param uri The element's Namespace URI.
298       * @param localName The element's local name.
299       * @exception org.xml.sax.SAXException If a filter
300       * further down the chain raises an exception.
301       * @see #emptyElement(String, String, String, Attributes)
302       */

303     public void emptyElement (String JavaDoc uri, String JavaDoc localName)
304     throws SAXException JavaDoc
305     {
306         emptyElement(uri, localName, "", EMPTY_ATTS);
307     }
308     
309     
310     /**
311      * Add an empty element without a Namespace URI or qname.
312      *
313      * <p>This method will provide an empty string for the
314      * Namespace URI, and empty string for the qualified name.
315      * It invokes
316      * {@link #emptyElement(String, String, String, Attributes)}
317      * directly.</p>
318      *
319      * @param localName The element's local name.
320      * @param atts The element's attribute list.
321      * @exception org.xml.sax.SAXException If a filter
322      * further down the chain raises an exception.
323      * @see org.xml.sax.ContentHandler#startElement
324      */

325     public void emptyElement (String JavaDoc localName, Attributes JavaDoc atts)
326     throws SAXException JavaDoc
327     {
328         emptyElement("", localName, "", atts);
329     }
330
331
332     /**
333      * Add an empty element without a Namespace URI, qname or attributes.
334      *
335      * <p>This method will supply an empty string for the qname,
336      * and empty string for the Namespace URI, and an empty
337      * attribute list. It invokes
338      * {@link #emptyElement(String, String, String, Attributes)}
339      * directly.</p>
340      *
341      * @param localName The element's local name.
342      * @exception org.xml.sax.SAXException If a filter
343      * further down the chain raises an exception.
344       * @see #emptyElement(String, String, String, Attributes)
345      */

346     public void emptyElement (String JavaDoc localName)
347     throws SAXException JavaDoc
348     {
349         emptyElement("", localName, "", EMPTY_ATTS);
350     }
351
352
353     /**
354      * Add an element with character data content.
355      *
356      * <p>This is a convenience method to add a complete element
357      * with character data content, including the start tag
358      * and end tag.</p>
359      *
360      * <p>This method invokes
361      * {@link @see org.xml.sax.ContentHandler#startElement},
362      * followed by
363      * {@link #characters(String)}, followed by
364      * {@link @see org.xml.sax.ContentHandler#endElement}.</p>
365      *
366      * @param uri The element's Namespace URI.
367      * @param localName The element's local name.
368      * @param qName The element's default qualified name.
369      * @param atts The element's attributes.
370      * @param content The character data content.
371      * @exception org.xml.sax.SAXException If a filter
372      * further down the chain raises an exception.
373      * @see org.xml.sax.ContentHandler#startElement
374      * @see #characters(String)
375      * @see org.xml.sax.ContentHandler#endElement
376      */

377     public void dataElement (String JavaDoc uri, String JavaDoc localName,
378                              String JavaDoc qName, Attributes JavaDoc atts,
379                              String JavaDoc content)
380     throws SAXException JavaDoc
381     {
382         startElement(uri, localName, qName, atts);
383         characters(content);
384         endElement(uri, localName, qName);
385     }
386
387
388     /**
389      * Add an element with character data content but no qname or attributes.
390      *
391      * <p>This is a convenience method to add a complete element
392      * with character data content, including the start tag
393      * and end tag. This method provides an empty string
394      * for the qname and an empty attribute list. It invokes
395      * {@link #dataElement(String, String, String, Attributes, String)}}
396      * directly.</p>
397      *
398      * @param uri The element's Namespace URI.
399      * @param localName The element's local name.
400      * @param content The character data content.
401      * @exception org.xml.sax.SAXException If a filter
402      * further down the chain raises an exception.
403      * @see org.xml.sax.ContentHandler#startElement
404      * @see #characters(String)
405      * @see org.xml.sax.ContentHandler#endElement
406      */

407     public void dataElement (String JavaDoc uri, String JavaDoc localName, String JavaDoc content)
408     throws SAXException JavaDoc
409     {
410         dataElement(uri, localName, "", EMPTY_ATTS, content);
411     }
412
413
414     /**
415      * Add an element with character data content but no Namespace URI or qname.
416      *
417      * <p>This is a convenience method to add a complete element
418      * with character data content, including the start tag
419      * and end tag. The method provides an empty string for the
420      * Namespace URI, and empty string for the qualified name. It invokes
421      * {@link #dataElement(String, String, String, Attributes, String)}}
422      * directly.</p>
423      *
424      * @param localName The element's local name.
425      * @param atts The element's attributes.
426      * @param content The character data content.
427      * @exception org.xml.sax.SAXException If a filter
428      * further down the chain raises an exception.
429      * @see org.xml.sax.ContentHandler#startElement
430      * @see #characters(String)
431      * @see org.xml.sax.ContentHandler#endElement
432      */

433     public void dataElement (String JavaDoc localName, Attributes JavaDoc atts, String JavaDoc content)
434     throws SAXException JavaDoc
435     {
436         dataElement("", localName, "", atts, content);
437     }
438
439
440     /**
441      * Add an element with character data content but no attributes
442      * or Namespace URI.
443      *
444      * <p>This is a convenience method to add a complete element
445      * with character data content, including the start tag
446      * and end tag. The method provides an empty string for the
447      * Namespace URI, and empty string for the qualified name,
448      * and an empty attribute list. It invokes
449      * {@link #dataElement(String, String, String, Attributes, String)}}
450      * directly.</p>
451      *
452      * @param localName The element's local name.
453      * @param content The character data content.
454      * @exception org.xml.sax.SAXException If a filter
455      * further down the chain raises an exception.
456      * @see org.xml.sax.ContentHandler#startElement
457      * @see #characters(String)
458      * @see org.xml.sax.ContentHandler#endElement
459      */

460     public void dataElement (String JavaDoc localName, String JavaDoc content)
461     throws SAXException JavaDoc
462     {
463         dataElement("", localName, "", EMPTY_ATTS, content);
464     }
465
466
467     /**
468      * Add a string of character data, with XML escaping.
469      *
470      * <p>This is a convenience method that takes an XML
471      * String, converts it to a character array, then invokes
472      * {@link @see org.xml.sax.ContentHandler#characters}.</p>
473      *
474      * @param data The character data.
475      * @exception org.xml.sax.SAXException If a filter
476      * further down the chain raises an exception.
477      * @see @see org.xml.sax.ContentHandler#characters
478      */

479     public void characters (String JavaDoc data)
480     throws SAXException JavaDoc
481     {
482         char ch[] = data.toCharArray();
483         characters(ch, 0, ch.length);
484     }
485
486
487
488     ////////////////////////////////////////////////////////////////////
489
// Override org.xml.sax.helpers.XMLFilterImpl methods.
490
////////////////////////////////////////////////////////////////////
491

492
493     /**
494      * Set the value of a property.
495      *
496      * <p>This will always fail if the parent is null.</p>
497      *
498      * @param name The property name.
499      * @param state The requested property value.
500      * @exception org.xml.sax.SAXNotRecognizedException When the
501      * XMLReader does not recognize the property name.
502      * @exception org.xml.sax.SAXNotSupportedException When the
503      * XMLReader recognizes the property name but
504      * cannot set the requested value.
505      * @see org.xml.sax.XMLReader#setProperty
506      */

507     public void setProperty (String JavaDoc name, Object JavaDoc value)
508     throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc
509     {
510         for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
511             if (LEXICAL_HANDLER_NAMES[i].equals(name)) {
512                 setLexicalHandler((LexicalHandler JavaDoc) value);
513                 return;
514             }
515         }
516         super.setProperty(name, value);
517     }
518     
519     
520     /**
521      * Look up the value of a property.
522      *
523      * @param name The property name.
524      * @return The current value of the property.
525      * @exception org.xml.sax.SAXNotRecognizedException When the
526      * XMLReader does not recognize the feature name.
527      * @exception org.xml.sax.SAXNotSupportedException When the
528      * XMLReader recognizes the property name but
529      * cannot determine its value at this time.
530      * @see org.xml.sax.XMLReader#setFeature
531      */

532     public Object JavaDoc getProperty (String JavaDoc name)
533     throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc
534     {
535         for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
536             if (LEXICAL_HANDLER_NAMES[i].equals(name)) {
537                 return getLexicalHandler();
538             }
539         }
540         return super.getProperty(name);
541     }
542
543
544     /**
545      * Parse a document.
546      *
547      * @param input The input source for the document entity.
548      * @exception org.xml.sax.SAXException Any SAX exception, possibly
549      * wrapping another exception.
550      * @exception java.io.IOException An IO exception from the parser,
551      * possibly from a byte stream or character stream
552      * supplied by the application.
553      * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
554      */

555     public void parse (InputSource JavaDoc input)
556     throws SAXException JavaDoc, IOException JavaDoc
557     {
558         installLexicalHandler();
559         super.parse(input);
560     }
561
562
563
564     ////////////////////////////////////////////////////////////////////
565
// Registration of org.xml.sax.ext.LexicalHandler.
566
////////////////////////////////////////////////////////////////////
567

568
569     /**
570      * Set the lexical handler.
571      *
572      * @param handler The new lexical handler.
573      * @exception java.lang.NullPointerException If the handler
574      * is null.
575      */

576     public void setLexicalHandler (LexicalHandler JavaDoc handler)
577     {
578         if (handler == null) {
579             throw new NullPointerException JavaDoc("Null lexical handler");
580         } else {
581             lexicalHandler = handler;
582         }
583     }
584     
585     
586     /**
587      * Get the current lexical handler.
588      *
589      * @return The current lexical handler, or null if none was set.
590      */

591     public LexicalHandler JavaDoc getLexicalHandler ()
592     {
593         return lexicalHandler;
594     }
595
596
597
598     ////////////////////////////////////////////////////////////////////
599
// Implementation of org.xml.sax.ext.LexicalHandler.
600
////////////////////////////////////////////////////////////////////
601

602
603     /**
604      * Filter a start DTD event.
605      *
606      * @param name The document type name.
607      * @param publicId The declared public identifier for the
608      * external DTD subset, or null if none was declared.
609      * @param systemId The declared system identifier for the
610      * external DTD subset, or null if none was declared.
611      * @exception org.xml.sax.SAXException If a filter
612      * further down the chain raises an exception.
613      * @see org.xml.sax.ext.LexicalHandler#startDTD
614      */

615     public void startDTD(String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId)
616     throws SAXException JavaDoc {
617         if (lexicalHandler != null) {
618             lexicalHandler.startDTD(name, publicId, systemId);
619         }
620     }
621
622
623     /**
624      * Filter a end DTD event.
625      *
626      * @exception org.xml.sax.SAXException If a filter
627      * further down the chain raises an exception.
628      * @see org.xml.sax.ext.LexicalHandler#endDTD
629      */

630     public void endDTD()
631     throws SAXException JavaDoc {
632         if (lexicalHandler != null) {
633             lexicalHandler.endDTD();
634         }
635     }
636
637
638     /*
639      * Filter a start entity event.
640      *
641      * @param name The name of the entity. If it is a parameter
642      * entity, the name will begin with '%', and if it is the
643      * external DTD subset, it will be "[dtd]".
644      * @exception org.xml.sax.SAXException If a filter
645      * further down the chain raises an exception.
646      * @see org.xml.sax.ext.LexicalHandler#startEntity
647      */

648     public void startEntity(String JavaDoc name)
649     throws SAXException JavaDoc {
650         if (lexicalHandler != null) {
651             lexicalHandler.startEntity(name);
652         }
653     }
654
655
656     /*
657      * Filter a end entity event.
658      *
659      * @param name The name of the entity that is ending.
660      * @exception org.xml.sax.SAXException If a filter
661      * further down the chain raises an exception.
662      * @see org.xml.sax.ext.LexicalHandler#endEntity
663      */

664     public void endEntity(String JavaDoc name)
665     throws SAXException JavaDoc {
666         if (lexicalHandler != null) {
667             lexicalHandler.endEntity(name);
668         }
669     }
670
671
672     /*
673      * Filter a start CDATA event.
674      *
675      * @exception org.xml.sax.SAXException If a filter
676      * further down the chain raises an exception.
677      * @see org.xml.sax.ext.LexicalHandler#startCDATA
678      */

679     public void startCDATA()
680     throws SAXException JavaDoc {
681         if (lexicalHandler != null) {
682             lexicalHandler.startCDATA();
683         }
684     }
685
686
687     /*
688      * Filter a end CDATA event.
689      *
690      * @exception org.xml.sax.SAXException If a filter
691      * further down the chain raises an exception.
692      * @see org.xml.sax.ext.LexicalHandler#endCDATA
693      */

694     public void endCDATA()
695     throws SAXException JavaDoc {
696         if (lexicalHandler != null) {
697             lexicalHandler.endCDATA();
698         }
699     }
700
701
702     /*
703      * Filter a comment event.
704      *
705      * @param ch An array holding the characters in the comment.
706      * @param start The starting position in the array.
707      * @param length The number of characters to use from the array.
708      * @exception org.xml.sax.SAXException If a filter
709      * further down the chain raises an exception.
710      * @see org.xml.sax.ext.LexicalHandler#comment
711      */

712     public void comment(char[] ch, int start, int length)
713     throws SAXException JavaDoc {
714         if (lexicalHandler != null) {
715             lexicalHandler.comment(ch, start, length);
716         }
717     }
718
719
720
721     ////////////////////////////////////////////////////////////////////
722
// Internal methods.
723
////////////////////////////////////////////////////////////////////
724

725
726     /**
727      * Installs lexical handler before a parse.
728      *
729      * <p>Before every parse, check whether the parent is
730      * non-null, and re-register the filter for the lexical
731      * events.</p>
732      */

733     private void installLexicalHandler ()
734     {
735         XMLReader JavaDoc parent = getParent();
736         if (parent == null) {
737             throw new NullPointerException JavaDoc("No parent for filter");
738         }
739         // try to register for lexical events
740
for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
741             try {
742                 parent.setProperty(LEXICAL_HANDLER_NAMES[i], this);
743                 break;
744             }
745             catch (SAXNotRecognizedException JavaDoc ex) {
746                 // ignore
747
}
748             catch (SAXNotSupportedException JavaDoc ex) {
749                 // ignore
750
}
751         }
752     }
753
754
755
756     ////////////////////////////////////////////////////////////////////
757
// Internal state.
758
////////////////////////////////////////////////////////////////////
759

760
761     private LexicalHandler JavaDoc lexicalHandler = null;
762
763
764
765     ////////////////////////////////////////////////////////////////////
766
// Constants.
767
////////////////////////////////////////////////////////////////////
768

769
770     protected static final Attributes JavaDoc EMPTY_ATTS = new AttributesImpl JavaDoc();
771
772     protected static final String JavaDoc[] LEXICAL_HANDLER_NAMES = {
773         "http://xml.org/sax/properties/lexical-handler",
774         "http://xml.org/sax/handlers/LexicalHandler"
775     };
776
777
778 }
779
780 // end of XMLFilterBase.java
781
Popular Tags