APIdia Launch Partner
Top Description Constructors Methods
jdk.internal.util.xml

public abstract Class SAXParser

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.util.xml.impl.SAXParserImpl
Imports
java.io.File, .IOException, .InputStream, jdk.internal.org.xml.sax.InputSource, .SAXException, .XMLReader, jdk.internal.org.xml.sax.helpers.DefaultHandler

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.

As the content is parsed by the underlying parser, methods of the given org.xml.sax.helpers.DefaultHandler are called.

Implementors 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.

Authors
Jeff Suttor, Joe Wang This is a subset of that in JAXP, javax.xml.parsers.SAXParser
Version
$Revision: 1.8 $, $Date: 2010-11-01 04:36:09 $

Constructor Summary

AccessConstructor and Description
protected
SAXParser()

Protected constructor to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
public abstract XMLReader

Returns:

The XMLReader that is encapsulated by the implementation of this class.
getXMLReader
()

Returns the org.xml.sax.XMLReader that is encapsulated by the implementation of this class.

public abstract boolean

Returns:

true if this parser is configured to understand namespaces; false otherwise.
isNamespaceAware
()

Indicates whether or not this parser is configured to understand namespaces.

public abstract boolean

Returns:

true if this parser is configured to validate XML documents; false otherwise.
isValidating
()

Indicates whether or not this parser is configured to validate XML documents.

public boolean

Returns:

the return value of the SAXParserFactory#isXIncludeAware() when this parser was created from factory.
isXIncludeAware
()

Get the XInclude processing mode for this parser.

public void
parse(InputStream
InputStream containing the content to be parsed.
is
,
DefaultHandler
The SAX DefaultHandler to use.
dh
)

Parse the content of the given java.io.InputStream instance as XML using the specified org.xml.sax.helpers.DefaultHandler.

public void
parse(String
The location of the content to be parsed.
uri
,
DefaultHandler
The SAX DefaultHandler to use.
dh
)

Parse the content described by the giving Uniform Resource Identifier (URI) as XML using the specified org.xml.sax.helpers.DefaultHandler.

public void
parse(File
The file containing the XML to parse
f
,
DefaultHandler
The SAX DefaultHandler to use.
dh
)

Parse the content of the file specified as XML using the specified org.xml.sax.helpers.DefaultHandler.

public void
parse(InputSource
The InputSource containing the content to be parsed.
is
,
DefaultHandler
The SAX DefaultHandler to use.
dh
)

Parse the content given org.xml.sax.InputSource as XML using the specified org.xml.sax.helpers.DefaultHandler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SAXParserback to summary
protected SAXParser()

Protected constructor to prevent instantiation.

Method Detail

getXMLReaderback to summary
public abstract XMLReader getXMLReader() throws SAXException

Returns the org.xml.sax.XMLReader that is encapsulated by the implementation of this class.

Returns:XMLReader

The XMLReader that is encapsulated by the implementation of this class.

Exceptions
SAXException:
If any SAX errors occur during processing.
isNamespaceAwareback to summary
public abstract boolean isNamespaceAware()

Indicates whether or not this parser is configured to understand namespaces.

Returns:boolean

true if this parser is configured to understand namespaces; false otherwise.

isValidatingback to summary
public abstract boolean isValidating()

Indicates whether or not this parser is configured to validate XML documents.

Returns:boolean

true if this parser is configured to validate XML documents; false otherwise.

isXIncludeAwareback to summary
public boolean isXIncludeAware()

Get the XInclude processing mode for this parser.

Returns:boolean

the return value of the SAXParserFactory#isXIncludeAware() when this parser was created from factory.

Exceptions
UnsupportedOperationException:
When implementation does not override this method
Since
1.5
See Also
SAXParserFactory#setXIncludeAware(boolean)
parseback to summary
public void parse(InputStream is, DefaultHandler dh) throws SAXException, IOException

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
SAXException:
If any SAX errors occur during processing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the given InputStream is null.
See Also
org.xml.sax.DocumentHandler
parseback to summary
public void parse(String uri, DefaultHandler dh) throws SAXException, IOException

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
SAXException:
If any SAX errors occur during processing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the uri is null.
See Also
org.xml.sax.DocumentHandler
parseback to summary
public void parse(File f, DefaultHandler dh) throws SAXException, IOException

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
SAXException:
If any SAX errors occur during processing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the File object is null.
See Also
org.xml.sax.DocumentHandler
parseback to summary
public void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException

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
SAXException:
If any SAX errors occur during processing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the InputSource object is null.
See Also
org.xml.sax.DocumentHandler