< prev index next >

src/java.xml/share/classes/org/xml/sax/helpers/ParserFactory.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * @version 2.0.1 (sax2r2)
  54  */
  55 @SuppressWarnings( "deprecation" )
  56 @Deprecated(since="1.5")
  57 public class ParserFactory {
  58 
  59     /**
  60      * Private null constructor.
  61      */
  62     private ParserFactory ()
  63     {
  64     }
  65 
  66 
  67     /**
  68      * Create a new SAX parser using the `org.xml.sax.parser' system property.
  69      *
  70      * <p>The named class must exist and must implement the
  71      * {@link org.xml.sax.Parser Parser} interface.</p>
  72      *
  73      * @exception java.lang.NullPointerException There is no value

  74      *            for the `org.xml.sax.parser' system property.
  75      * @exception java.lang.ClassNotFoundException The SAX parser
  76      *            class was not found (check your CLASSPATH).
  77      * @exception IllegalAccessException The SAX parser class was
  78      *            found, but you do not have permission to load
  79      *            it.
  80      * @exception InstantiationException The SAX parser class was
  81      *            found but could not be instantiated.
  82      * @exception java.lang.ClassCastException The SAX parser class
  83      *            was found and instantiated, but does not implement
  84      *            org.xml.sax.Parser.
  85      * @see #makeParser(java.lang.String)
  86      * @see org.xml.sax.Parser
  87      */
  88     public static org.xml.sax.Parser makeParser ()
  89         throws ClassNotFoundException,
  90         IllegalAccessException,
  91         InstantiationException,
  92         NullPointerException,
  93         ClassCastException
  94     {
  95         String className = SecuritySupport.getSystemProperty("org.xml.sax.parser");
  96         if (className == null) {
  97             throw new NullPointerException("No value for sax.parser property");
  98         } else {
  99             return makeParser(className);
 100         }
 101     }
 102 
 103 
 104     /**
 105      * Create a new SAX parser object using the class name provided.
 106      *
 107      * <p>The named class must exist and must implement the
 108      * {@link org.xml.sax.Parser Parser} interface.</p>
 109      *
 110      * @param className A string containing the name of the
 111      *                  SAX parser class.
 112      * @exception java.lang.ClassNotFoundException The SAX parser

 113      *            class was not found (check your CLASSPATH).
 114      * @exception IllegalAccessException The SAX parser class was
 115      *            found, but you do not have permission to load
 116      *            it.
 117      * @exception InstantiationException The SAX parser class was
 118      *            found but could not be instantiated.
 119      * @exception java.lang.ClassCastException The SAX parser class
 120      *            was found and instantiated, but does not implement
 121      *            org.xml.sax.Parser.
 122      * @see #makeParser()
 123      * @see org.xml.sax.Parser
 124      */
 125     public static org.xml.sax.Parser makeParser (String className)
 126         throws ClassNotFoundException,
 127         IllegalAccessException,
 128         InstantiationException,
 129         ClassCastException
 130     {
 131         return NewInstance.newInstance (org.xml.sax.Parser.class,
 132                 SecuritySupport.getClassLoader(), className);
 133     }
 134 
 135 }
   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * @version 2.0.1 (sax2r2)
  54  */
  55 @SuppressWarnings( "deprecation" )
  56 @Deprecated(since="1.5")
  57 public class ParserFactory {
  58 
  59     /**
  60      * Private null constructor.
  61      */
  62     private ParserFactory ()
  63     {
  64     }
  65 
  66 
  67     /**
  68      * Create a new SAX parser using the `org.xml.sax.parser' system property.
  69      *
  70      * <p>The named class must exist and must implement the
  71      * {@link org.xml.sax.Parser Parser} interface.</p>
  72      *
  73      * @return a new SAX parser
  74      * @throws java.lang.NullPointerException There is no value
  75      *            for the `org.xml.sax.parser' system property.
  76      * @throws java.lang.ClassNotFoundException The SAX parser
  77      *            class was not found (check your CLASSPATH).
  78      * @throws IllegalAccessException The SAX parser class was
  79      *            found, but you do not have permission to load
  80      *            it.
  81      * @throws InstantiationException The SAX parser class was
  82      *            found but could not be instantiated.
  83      * @throws java.lang.ClassCastException The SAX parser class
  84      *            was found and instantiated, but does not implement
  85      *            org.xml.sax.Parser.
  86      * @see #makeParser(java.lang.String)
  87      * @see org.xml.sax.Parser
  88      */
  89     public static org.xml.sax.Parser makeParser ()
  90         throws ClassNotFoundException,
  91         IllegalAccessException,
  92         InstantiationException,
  93         NullPointerException,
  94         ClassCastException
  95     {
  96         String className = SecuritySupport.getSystemProperty("org.xml.sax.parser");
  97         if (className == null) {
  98             throw new NullPointerException("No value for sax.parser property");
  99         } else {
 100             return makeParser(className);
 101         }
 102     }
 103 
 104 
 105     /**
 106      * Create a new SAX parser object using the class name provided.
 107      *
 108      * <p>The named class must exist and must implement the
 109      * {@link org.xml.sax.Parser Parser} interface.</p>
 110      *
 111      * @param className A string containing the name of the
 112      *                  SAX parser class.
 113      * @return a new SAX parser
 114      * @throws java.lang.ClassNotFoundException The SAX parser
 115      *            class was not found (check your CLASSPATH).
 116      * @throws IllegalAccessException The SAX parser class was
 117      *            found, but you do not have permission to load
 118      *            it.
 119      * @throws InstantiationException The SAX parser class was
 120      *            found but could not be instantiated.
 121      * @throws java.lang.ClassCastException The SAX parser class
 122      *            was found and instantiated, but does not implement
 123      *            org.xml.sax.Parser.
 124      * @see #makeParser()
 125      * @see org.xml.sax.Parser
 126      */
 127     public static org.xml.sax.Parser makeParser (String className)
 128         throws ClassNotFoundException,
 129         IllegalAccessException,
 130         InstantiationException,
 131         ClassCastException
 132     {
 133         return NewInstance.newInstance (org.xml.sax.Parser.class,
 134                 SecuritySupport.getClassLoader(), className);
 135     }
 136 
 137 }
< prev index next >