SAXParser
abstract class SAXParser
kotlin.Any | |
↳ | javax.xml.parsers.SAXParser |
Defines the API that wraps an org.xml.sax.XMLReader
implementation class. In JAXP 1.0, this class wrapped the org.xml.sax.Parser
interface, however this interface was replaced by the org.xml.sax.XMLReader
. For ease of transition, this class continues to support the same name and interface as well as supporting new methods. An instance of this class can be obtained from the javax.xml.parsers.SAXParserFactory#newSAXParser()
method. Once an instance of this class is obtained, XML can be parsed from a variety of input sources. These input sources are InputStreams, Files, URLs, and SAX InputSources.
This static method creates a new factory instance based on a system property setting or uses the platform default if no property has been defined.
The system property that controls which Factory implementation to create is named "javax.xml.parsers.SAXParserFactory"
. This property names a class that is a concrete subclass of this abstract class. If no property is defined, a platform default will be used.
org.xml.sax.HandlerBase
or the org.xml.sax.helpers.DefaultHandler
are called.
Implementations of this class which wrap an underlying implementation can consider using the org.xml.sax.helpers.ParserAdapter
class to initially adapt their SAX1 implementation to work under this revised class.
Summary
Protected constructors | |
---|---|
Protected constructor to prevent instantiation. |
Public methods | |
---|---|
abstract Parser! |
Returns the SAX parser that is encapsulated by the implementation of this class. |
abstract Any! |
getProperty(name: String!) Returns the particular property requested for in the underlying implementation of |
open Schema! |
Get a reference to the the |
abstract XMLReader! |
Returns the |
abstract Boolean |
Indicates whether or not this parser is configured to understand namespaces. |
abstract Boolean |
Indicates whether or not this parser is configured to validate XML documents. |
open Boolean |
Get the XInclude processing mode for this parser. |
open Unit |
parse(f: File!, hb: HandlerBase!) Parse the content of the file specified as XML using the specified |
open Unit |
parse(f: File!, dh: DefaultHandler!) Parse the content of the file specified as XML using the specified |
open Unit |
parse(is: InputStream!, hb: HandlerBase!) Parse the content of the given |
open Unit |
parse(is: InputStream!, hb: HandlerBase!, systemId: String!) Parse the content of the given |
open Unit |
parse(is: InputStream!, dh: DefaultHandler!) Parse the content of the given |
open Unit |
parse(is: InputStream!, dh: DefaultHandler!, systemId: String!) Parse the content of the given |
open Unit |
parse(uri: String!, hb: HandlerBase!) Parse the content described by the giving Uniform Resource Identifier (URI) as XML using the specified |
open Unit |
parse(uri: String!, dh: DefaultHandler!) Parse the content described by the giving Uniform Resource Identifier (URI) as XML using the specified |
open Unit |
parse(is: InputSource!, hb: HandlerBase!) Parse the content given |
open Unit |
parse(is: InputSource!, dh: DefaultHandler!) Parse the content given |
open Unit |
reset() Reset this |
abstract Unit |
setProperty(name: String!, value: Any!) Sets the particular property in the underlying implementation of |
Protected constructors
SAXParser
protected SAXParser()
Protected constructor to prevent instantiation. Use javax.xml.parsers.SAXParserFactory#newSAXParser()
.
Public methods
getParser
abstract fun getParser(): Parser!
Returns the SAX parser that is encapsulated by the implementation of this class.
Return | |
---|---|
Parser! |
The SAX parser that is encapsulated by the implementation of this class. |
Exceptions | |
---|---|
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
getProperty
abstract fun getProperty(name: String!): Any!
Returns the particular property requested for in the underlying implementation of org.xml.sax.XMLReader
.
Parameters | |
---|---|
name |
String!: The name of the property to be retrieved. |
Return | |
---|---|
Any! |
Value of the requested property. |
Exceptions | |
---|---|
org.xml.sax.SAXNotRecognizedException |
When the underlying XMLReader does not recognize the property name. |
org.xml.sax.SAXNotSupportedException |
When the underlying XMLReader recognizes the property name but doesn't support the property. |
See Also
getSchema
open fun getSchema(): Schema!
Get a reference to the the Schema
being used by the XML processor.
If no schema is being used, null
is returned.
Return | |
---|---|
Schema! |
Schema being used or null if none in use |
Exceptions | |
---|---|
java.lang.UnsupportedOperationException |
For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
getXMLReader
abstract fun getXMLReader(): XMLReader!
Returns the org.xml.sax.XMLReader
that is encapsulated by the implementation of this class.
Return | |
---|---|
XMLReader! |
The XMLReader that is encapsulated by the implementation of this class. |
Exceptions | |
---|---|
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
isNamespaceAware
abstract fun isNamespaceAware(): Boolean
Indicates whether or not this parser is configured to understand namespaces.
Return | |
---|---|
Boolean |
true if this parser is configured to understand namespaces; false otherwise. |
isValidating
abstract fun isValidating(): Boolean
Indicates whether or not this parser is configured to validate XML documents.
Return | |
---|---|
Boolean |
true if this parser is configured to validate XML documents; false otherwise. |
isXIncludeAware
open fun isXIncludeAware(): Boolean
Get the XInclude processing mode for this parser.
Return | |
---|---|
Boolean |
the return value of the SAXParserFactory.isXIncludeAware() when this parser was created from factory. |
Exceptions | |
---|---|
java.lang.UnsupportedOperationException |
For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
parse
open fun parse(
f: File!,
hb: HandlerBase!
): Unit
Parse the content of the file specified as XML using the specified org.xml.sax.HandlerBase
. Use of the DefaultHandler version of this method is recommended as the HandlerBase class has been deprecated in SAX 2.0
Parameters | |
---|---|
f |
File!: The file containing the XML to parse |
hb |
HandlerBase!: The SAX HandlerBase to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the File object is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
f: File!,
dh: DefaultHandler!
): Unit
Parse the content of the file specified as XML using the specified org.xml.sax.helpers.DefaultHandler
.
Parameters | |
---|---|
f |
File!: The file containing the XML to parse |
dh |
DefaultHandler!: The SAX DefaultHandler to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the File object is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
is: InputStream!,
hb: HandlerBase!
): Unit
Parse the content of the given java.io.InputStream
instance as XML using the specified org.xml.sax.HandlerBase
. Use of the DefaultHandler version of this method is recommended as the HandlerBase class has been deprecated in SAX 2.0.
Parameters | |
---|---|
is |
InputStream!: InputStream containing the content to be parsed. |
hb |
HandlerBase!: The SAX HandlerBase to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the given InputStream is null. |
org.xml.sax.SAXException |
If parse produces a SAX error. |
java.io.IOException |
If an IO error occurs interacting with the InputStream . |
See Also
parse
open fun parse(
is: InputStream!,
hb: HandlerBase!,
systemId: String!
): Unit
Parse the content of the given java.io.InputStream
instance as XML using the specified org.xml.sax.HandlerBase
. Use of the DefaultHandler version of this method is recommended as the HandlerBase class has been deprecated in SAX 2.0.
Parameters | |
---|---|
is |
InputStream!: InputStream containing the content to be parsed. |
hb |
HandlerBase!: The SAX HandlerBase to use. |
systemId |
String!: The systemId which is needed for resolving relative URIs. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the given InputStream is null . |
java.io.IOException |
If any IO error occurs interacting with the InputStream . |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
is: InputStream!,
dh: DefaultHandler!
): Unit
Parse the content of the given java.io.InputStream
instance as XML using the specified org.xml.sax.helpers.DefaultHandler
.
Parameters | |
---|---|
is |
InputStream!: InputStream containing the content to be parsed. |
dh |
DefaultHandler!: The SAX DefaultHandler to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the given InputStream is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
is: InputStream!,
dh: DefaultHandler!,
systemId: String!
): Unit
Parse the content of the given java.io.InputStream
instance as XML using the specified org.xml.sax.helpers.DefaultHandler
.
Parameters | |
---|---|
is |
InputStream!: InputStream containing the content to be parsed. |
dh |
DefaultHandler!: The SAX DefaultHandler to use. |
systemId |
String!: The systemId which is needed for resolving relative URIs. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the given InputStream is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
uri: String!,
hb: HandlerBase!
): Unit
Parse the content described by the giving Uniform Resource Identifier (URI) as XML using the specified org.xml.sax.HandlerBase
. Use of the DefaultHandler version of this method is recommended as the HandlerBase
class has been deprecated in SAX 2.0
Parameters | |
---|---|
uri |
String!: The location of the content to be parsed. |
hb |
HandlerBase!: The SAX HandlerBase to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the uri is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
uri: String!,
dh: DefaultHandler!
): Unit
Parse the content described by the giving Uniform Resource Identifier (URI) as XML using the specified org.xml.sax.helpers.DefaultHandler
.
Parameters | |
---|---|
uri |
String!: The location of the content to be parsed. |
dh |
DefaultHandler!: The SAX DefaultHandler to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the uri is null. |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
is: InputSource!,
hb: HandlerBase!
): Unit
Parse the content given org.xml.sax.InputSource
as XML using the specified org.xml.sax.HandlerBase
. Use of the DefaultHandler version of this method is recommended as the HandlerBase class has been deprecated in SAX 2.0
Parameters | |
---|---|
is |
InputSource!: The InputSource containing the content to be parsed. |
hb |
HandlerBase!: The SAX HandlerBase to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the InputSource object is null . |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
parse
open fun parse(
is: InputSource!,
dh: DefaultHandler!
): Unit
Parse the content given org.xml.sax.InputSource
as XML using the specified org.xml.sax.helpers.DefaultHandler
.
Parameters | |
---|---|
is |
InputSource!: The InputSource containing the content to be parsed. |
dh |
DefaultHandler!: The SAX DefaultHandler to use. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the InputSource object is null . |
java.io.IOException |
If any IO errors occur. |
org.xml.sax.SAXException |
If any SAX errors occur during processing. |
See Also
reset
open fun reset(): Unit
Reset this SAXParser
to its original configuration.
SAXParser
is reset to the same state as when it was created with SAXParserFactory.newSAXParser()
. reset()
is designed to allow the reuse of existing SAXParser
s thus saving resources associated with the creation of new SAXParser
s.
The reset SAXParser
is not guaranteed to have the same Schema
Object
, e.g. Object.equals(Object obj)
. It is guaranteed to have a functionally equal Schema
.
setProperty
abstract fun setProperty(
name: String!,
value: Any!
): Unit
Sets the particular property in the underlying implementation of org.xml.sax.XMLReader
. A list of the core features and properties can be found at http://sax.sourceforge.net/?selected=get-set.
Parameters | |
---|---|
name |
String!: The name of the property to be set. |
value |
Any!: The value of the property to be set. |
Exceptions | |
---|---|
org.xml.sax.SAXNotRecognizedException |
When the underlying XMLReader does not recognize the property name. |
org.xml.sax.SAXNotSupportedException |
When the underlying XMLReader recognizes the property name but doesn't support the property. |
See Also