View Javadoc

1   package net.sf.tomp.xtcl.test;
2   
3   import net.sf.tomp.xtcl.filter.DynamicMultiFilterImpl;
4   
5   import org.apache.commons.logging.Log;
6   import org.apache.commons.logging.LogFactory;
7   import org.xml.sax.SAXException;
8   import org.xml.sax.XMLFilter;
9   import org.xml.sax.XMLReader;
10  
11  import java.util.List;
12  
13  /***
14   * A trial MultiFilter for testing purposes.
15   * 
16   * @author tomp
17   */
18  public class MyMultiFilter extends DynamicMultiFilterImpl {
19      
20      private static Log log = LogFactory.getLog(MyMultiFilter.class);
21  
22      ////////////////////////////////////////////////////////////////////
23      // Constructors.
24      ////////////////////////////////////////////////////////////////////
25      public MyMultiFilter() throws SAXException {
26          super();
27          setupFilters();
28      }
29  
30      /***
31       * Creates a new MyMultiFilter object.
32       * 
33       * @param parent DOCUMENT ME!
34       * @throws SAXException DOCUMENT ME!
35       */
36      public MyMultiFilter(XMLReader parent) throws SAXException {
37          super(parent);
38          setupFilters();
39      }
40  
41      /***
42       * DOCUMENT ME!
43       * 
44       * @throws SAXException DOCUMENT ME!
45       */
46      protected void setupFilters() throws SAXException {
47          XMLFilter f1 = new org.xml.sax.helpers.XMLFilterImpl();
48  
49          addFilter(0, f1); // the first
50          log.debug("+++ added at 0 " + f1);
51  
52          XMLFilter f2 = new net.sf.tomp.xtcl.filter.XTFilterImpl();
53  
54          addFilter(0, f2); // at begin
55          log.debug("+++ added at 0 " + f2);
56  
57          XMLFilter f3 = new net.sf.tomp.xtcl.filter.XTFilterImpl();
58  
59          addFilter(2, f3); // at end
60          log.debug("+++ added at 2 " + f3);
61          log.debug("+++ filters: " + getFilters());
62  
63          /*
64           * System.out.println("+++ firstfilter: "+firstFilter);
65           * System.out.println("+++ lastfilter: "+lastFilter);
66           * System.out.println("+++ lastfilter.parent=:
67           * "+lastFilter.getParent()); System.out.println("+++
68           * secondfilter.parent=: "+getFilter(1).getParent());
69           * System.out.println("+++ firstfilter.parent=:
70           * "+firstFilter.getParent());
71           */
72      }
73  
74      /***
75       * DOCUMENT ME!
76       * 
77       * @return DOCUMENT ME!
78       */
79      public List getFilters() {
80          return filters;
81      }
82  }
83  
84  /*
85   * The contents of this file are subject to the Mozilla Public License Version
86   * 1.1 (the "License"); you may not use this file except in compliance with the
87   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
88   * Software distributed under the License is distributed on an "AS IS" basis,
89   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
90   * the specific language governing rights and limitations under the License. The
91   * Original Code is: all this file. The Initial Developer of the Original Code
92   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
93   */