ParserFactory
Stay organized with collections
Save and categorize content based on your preferences.
This class is deprecated.
This class works with the deprecated
Parser
interface.
Java-specific class for dynamically loading SAX parsers.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
Note: This class is designed to work with the now-deprecated
SAX1 Parser
class. SAX2 applications should use
XMLReaderFactory
instead.
ParserFactory is not part of the platform-independent definition
of SAX; it is an additional convenience class designed
specifically for Java XML application writers. SAX applications
can use the static methods in this class to allocate a SAX parser
dynamically at run-time based either on the value of the
`org.xml.sax.parser' system property or on a string containing the class
name.
Note that the application still requires an XML parser that
implements SAX1.
Public Method Summary
static
Parser
|
makeParser()
Create a new SAX parser using the `org.xml.sax.parser' system property.
|
static
Parser
|
makeParser( String className)
Create a new SAX parser object using the class name provided.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Methods
public
static
Parser
makeParser
()
Create a new SAX parser using the `org.xml.sax.parser' system property.
The named class must exist and must implement the
Parser
interface.
Returns
- the newly created parser.
public
static
Parser
makeParser
(String className)
Create a new SAX parser object using the class name provided.
The named class must exist and must implement the
Parser
interface.
Parameters
className |
A string containing the name of the
SAX parser class. |
Returns
- the newly created parser.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eParserFactory\u003c/code\u003e is a deprecated Java-specific class used for dynamically loading SAX parsers, designed to work with the now-deprecated SAX1 \u003ccode\u003eParser\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eSAX2 applications should use \u003ccode\u003eXMLReaderFactory\u003c/code\u003e instead of \u003ccode\u003eParserFactory\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eParserFactory\u003c/code\u003e provides two static methods: \u003ccode\u003emakeParser()\u003c/code\u003e to create a parser using the \u003ccode\u003eorg.xml.sax.parser\u003c/code\u003e system property and \u003ccode\u003emakeParser(String className)\u003c/code\u003e to create a parser using a specified class name.\u003c/p\u003e\n"],["\u003cp\u003eApplications using \u003ccode\u003eParserFactory\u003c/code\u003e still require an XML parser that implements SAX1.\u003c/p\u003e\n"]]],["`ParserFactory`, a deprecated Java class, dynamically loads SAX1 parsers. It provides static methods to create a parser instance at runtime. `makeParser()` uses the `org.xml.sax.parser` system property to identify the parser class, while `makeParser(String className)` utilizes a provided class name. Both methods ensure the specified class exists, is accessible, and implements the `Parser` interface, throwing exceptions if these conditions are unmet. SAX2 applications should instead use `XMLReaderFactory`.\n"],null,["# ParserFactory\n\npublic class **ParserFactory** extends [Object](../../../../../reference/java/lang/Object.html) \n\n\n**This class is deprecated.** \nThis class works with the deprecated\n[Parser](../../../../../reference/org/xml/sax/Parser.html)\ninterface.\n\nJava-specific class for dynamically loading SAX parsers.\n\n\u003e *This module, both source code and documentation, is in the\n\u003e Public Domain, and comes with **NO WARRANTY**.* See \u003chttp://www.saxproject.org\u003e for further information.\n\n**Note:** This class is designed to work with the now-deprecated\nSAX1 [Parser](../../../../../reference/org/xml/sax/Parser.html) class. SAX2 applications should use\n[XMLReaderFactory](../../../../../reference/org/xml/sax/helpers/XMLReaderFactory.html) instead.\n\nParserFactory is not part of the platform-independent definition\nof SAX; it is an additional convenience class designed\nspecifically for Java XML application writers. SAX applications\ncan use the static methods in this class to allocate a SAX parser\ndynamically at run-time based either on the value of the\n\\`org.xml.sax.parser' system property or on a string containing the class\nname.\n\nNote that the application still requires an XML parser that\nimplements SAX1.\n\n\u003cbr /\u003e\n\n### Public Method Summary\n\n|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Parser](../../../../../reference/org/xml/sax/Parser.html) | [makeParser](../../../../../reference/org/xml/sax/helpers/ParserFactory.html#makeParser())() Create a new SAX parser using the \\`org.xml.sax.parser' system property. |\n| static [Parser](../../../../../reference/org/xml/sax/Parser.html) | [makeParser](../../../../../reference/org/xml/sax/helpers/ParserFactory.html#makeParser(java.lang.String))([String](../../../../../reference/java/lang/String.html) className) Create a new SAX parser object using the class name provided. |\n\n### Inherited Method Summary\n\nFrom class [java.lang.Object](../../../../../reference/java/lang/Object.html) \n\n|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../../reference/java/lang/Object.html) | [clone](../../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../../reference/java/lang/String.html) | [toString](../../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Methods\n--------------\n\n#### public static [Parser](../../../../../reference/org/xml/sax/Parser.html)\n**makeParser**\n()\n\nCreate a new SAX parser using the \\`org.xml.sax.parser' system property.\n\nThe named class must exist and must implement the\n[Parser](../../../../../reference/org/xml/sax/Parser.html) interface.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- the newly created parser. \n\n##### Throws\n\n| [NullPointerException](../../../../../reference/java/lang/NullPointerException.html) | There is no value for the \\`org.xml.sax.parser' system property. |\n| [ClassNotFoundException](../../../../../reference/java/lang/ClassNotFoundException.html) | The SAX parser class was not found (check your CLASSPATH). |\n| [IllegalAccessException](../../../../../reference/java/lang/IllegalAccessException.html) | The SAX parser class was found, but you do not have permission to load it. |\n| [InstantiationException](../../../../../reference/java/lang/InstantiationException.html) | The SAX parser class was found but could not be instantiated. |\n| [ClassCastException](../../../../../reference/java/lang/ClassCastException.html) | The SAX parser class was found and instantiated, but does not implement org.xml.sax.Parser. |\n|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|\n\n##### See Also\n\n- [makeParser(java.lang.String)](../../../../../reference/org/xml/sax/helpers/ParserFactory.html#makeParser(java.lang.String))\n- [Parser](../../../../../reference/org/xml/sax/Parser.html) \n\n#### public static [Parser](../../../../../reference/org/xml/sax/Parser.html)\n**makeParser**\n([String](../../../../../reference/java/lang/String.html) className)\n\nCreate a new SAX parser object using the class name provided.\n\nThe named class must exist and must implement the\n[Parser](../../../../../reference/org/xml/sax/Parser.html) interface.\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| className | A string containing the name of the SAX parser class. |\n|-----------|-------------------------------------------------------|\n\n##### Returns\n\n- the newly created parser. \n\n##### Throws\n\n| [ClassNotFoundException](../../../../../reference/java/lang/ClassNotFoundException.html) | The SAX parser class was not found (check your CLASSPATH). |\n| [IllegalAccessException](../../../../../reference/java/lang/IllegalAccessException.html) | The SAX parser class was found, but you do not have permission to load it. |\n| [InstantiationException](../../../../../reference/java/lang/InstantiationException.html) | The SAX parser class was found but could not be instantiated. |\n| [ClassCastException](../../../../../reference/java/lang/ClassCastException.html) | The SAX parser class was found and instantiated, but does not implement org.xml.sax.Parser. |\n|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|\n\n##### See Also\n\n- [makeParser()](../../../../../reference/org/xml/sax/helpers/ParserFactory.html#makeParser())\n- [Parser](../../../../../reference/org/xml/sax/Parser.html)"]]