View Javadoc

1   package net.sf.tomp.xtcl.source;
2   
3   import net.sf.tomp.xml.sax.ParametrizedXMLReader;
4   
5   import org.xml.sax.InputSource;
6   import org.xml.sax.XMLReader;
7   
8   import javax.xml.transform.sax.SAXSource;
9   
10  /***
11   * DOCUMENT ME!
12   * 
13   * @author tomp
14   */
15  public class XTSourceFactoryImpl implements XTSourceFactory {
16      /***
17       * DOCUMENT ME!
18       * 
19       * @param className DOCUMENT ME!
20       * @param is DOCUMENT ME!
21       * @return DOCUMENT ME!
22       * @throws ClassNotFoundException DOCUMENT ME!
23       * @throws InstantiationException DOCUMENT ME!
24       * @throws IllegalAccessException DOCUMENT ME!
25       */
26      public SAXSource newSAXSource(String className, InputSource is)
27              throws ClassNotFoundException, InstantiationException,
28              IllegalAccessException {
29          Class readerClass = Class.forName(className);
30          XMLReader f = (XMLReader) readerClass.newInstance();
31  
32          if (f instanceof ParametrizedXMLReader) {
33              return new XTSAXSource((ParametrizedXMLReader) f, is);
34          } else {
35              return new SAXSource(f, is);
36          }
37      }
38  }
39  
40  /*
41   * The contents of this file are subject to the Mozilla Public License Version
42   * 1.1 (the "License"); you may not use this file except in compliance with the
43   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
44   * Software distributed under the License is distributed on an "AS IS" basis,
45   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
46   * the specific language governing rights and limitations under the License. The
47   * Original Code is: all this file. The Initial Developer of the Original Code
48   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
49   */