Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package org.xml.sax.helpers

File ParserFactory.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
56% of files have more coverage

Code metrics

2
5
3
1
123
30
4
0.8
1.67
3
1.33

Classes

Class Line # Actions
ParserFactory 43 5 4 10
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    // SAX parser factory.
2    // http://www.saxproject.org
3    // No warranty; no copyright -- use this as you will.
4    // $Id: ParserFactory.java,v 1.7 2002/01/30 20:52:36 dbrownell Exp $
5   
6    package org.xml.sax.helpers;
7   
8    import org.xml.sax.Parser;
9   
10   
11    /**
12    * Java-specific class for dynamically loading SAX parsers.
13    *
14    * <blockquote>
15    * <em>This module, both source code and documentation, is in the
16    * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
17    * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
18    * for further information.
19    * </blockquote>
20    *
21    * <p><strong>Note:</strong> This class is designed to work with the now-deprecated
22    * SAX1 {@link org.xml.sax.Parser Parser} class. SAX2 applications should use
23    * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.</p>
24    *
25    * <p>ParserFactory is not part of the platform-independent definition
26    * of SAX; it is an additional convenience class designed
27    * specifically for Java XML application writers. SAX applications
28    * can use the static methods in this class to allocate a SAX parser
29    * dynamically at run-time based either on the value of the
30    * `org.xml.sax.parser' system property or on a string containing the class
31    * name.</p>
32    *
33    * <p>Note that the application still requires an XML parser that
34    * implements SAX1.</p>
35    *
36    * @deprecated This class works with the deprecated
37    * {@link org.xml.sax.Parser Parser}
38    * interface.
39    * @since SAX 1.0
40    * @author David Megginson
41    * @version 2.0.1 (sax2r2)
42    */
 
43    public class ParserFactory {
44   
45   
46    /**
47    * Private null constructor.
48    */
 
49  0 toggle private ParserFactory ()
50    {
51    }
52   
53   
54    /**
55    * Create a new SAX parser using the `org.xml.sax.parser' system property.
56    *
57    * <p>The named class must exist and must implement the
58    * {@link org.xml.sax.Parser Parser} interface.</p>
59    *
60    * @exception java.lang.NullPointerException There is no value
61    * for the `org.xml.sax.parser' system property.
62    * @exception java.lang.ClassNotFoundException The SAX parser
63    * class was not found (check your CLASSPATH).
64    * @exception IllegalAccessException The SAX parser class was
65    * found, but you do not have permission to load
66    * it.
67    * @exception InstantiationException The SAX parser class was
68    * found but could not be instantiated.
69    * @exception java.lang.ClassCastException The SAX parser class
70    * was found and instantiated, but does not implement
71    * org.xml.sax.Parser.
72    * @see #makeParser(java.lang.String)
73    * @see org.xml.sax.Parser
74    */
 
75  0 toggle public static Parser makeParser ()
76    throws ClassNotFoundException,
77    IllegalAccessException,
78    InstantiationException,
79    NullPointerException,
80    ClassCastException
81    {
82  0 String className = System.getProperty("org.xml.sax.parser");
83  0 if (className == null) {
84  0 throw new NullPointerException("No value for sax.parser property");
85    } else {
86  0 return makeParser(className);
87    }
88    }
89   
90   
91    /**
92    * Create a new SAX parser object using the class name provided.
93    *
94    * <p>The named class must exist and must implement the
95    * {@link org.xml.sax.Parser Parser} interface.</p>
96    *
97    * @param className A string containing the name of the
98    * SAX parser class.
99    * @exception java.lang.ClassNotFoundException The SAX parser
100    * class was not found (check your CLASSPATH).
101    * @exception IllegalAccessException The SAX parser class was
102    * found, but you do not have permission to load
103    * it.
104    * @exception InstantiationException The SAX parser class was
105    * found but could not be instantiated.
106    * @exception java.lang.ClassCastException The SAX parser class
107    * was found and instantiated, but does not implement
108    * org.xml.sax.Parser.
109    * @see #makeParser()
110    * @see org.xml.sax.Parser
111    */
 
112  0 toggle public static Parser makeParser (String className)
113    throws ClassNotFoundException,
114    IllegalAccessException,
115    InstantiationException,
116    ClassCastException
117    {
118  0 return (Parser) NewInstance.newInstance (
119    NewInstance.getClassLoader (), className);
120    }
121   
122    }
123