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

pack-priv final Class ParserSAX

extends Parser
implements XMLReader, Locator
Class Inheritance
All Implemented Interfaces
jdk.internal.org.xml.sax.Locator, jdk.internal.org.xml.sax.XMLReader
Imports
java.io.IOException, .InputStream, jdk.internal.org.xml.sax.ContentHandler, .DTDHandler, .EntityResolver, .ErrorHandler, .InputSource, .Locator, .SAXException, .SAXParseException, .XMLReader, jdk.internal.org.xml.sax.helpers.DefaultHandler

XML non-validating push parser.

This non-validating parser conforms to Extensible Markup Language (XML) 1.0 and Namespaces in XML specifications. The API supported by the parser are CLDC and JSR-280, a JavaME subset of JAXP and SAX2.

See Also
org.xml.sax.XMLReader

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
private boolean
private boolean
private DefaultHandler
private ContentHandler
private DTDHandler
private EntityResolver
private ErrorHandler
Inherited from jdk.internal.util.xml.impl.Parser:
BUFFSIZE_PARSERBUFFSIZE_READEREOSEV_CDATEV_COMMEV_DTDEV_ELMEV_ELMEEV_ELMSEV_ENTEV_NULLEV_PIEV_TEXTEV_WSPCFAULTmAttLmAttrsmBuffmBuffIdxmDocmElmmEvtmInpmIsNSAwaremIsSAlonemIsSAloneSetmPhmPrefPH_AFTER_DOCPH_BEFORE_DOCPH_DOC_STARTPH_DOCELMPH_DOCELM_MISCPH_DTDPH_DTD_MISCPH_MISC_DTD

Constructor Summary

AccessConstructor and Description
public
ParserSAX()

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
bflash()

Implements abstract jdk.internal.util.xml.impl.Parser.bflash.

Reports characters and empties the parser's buffer.

protected void
bflash_ws()

Implements abstract jdk.internal.util.xml.impl.Parser.bflash_ws.

Reports white space characters and empties the parser's buffer.

protected void
comm(char[]
The comment text starting from first character.
text
,
int
The number of characters in comment.
length
)

Implements abstract jdk.internal.util.xml.impl.Parser.comm.

Reports a comment.

protected void
docType(String
The name of the entity.
name
,
String
The public identifier of the entity or null.
pubid
,
String
The system identifier of the entity or null.
sysid
)

Implements abstract jdk.internal.util.xml.impl.Parser.docType.

Reports document type.

public int

Returns:

Always returns -1 indicating the column number is not available.
getColumnNumber
()

Implements jdk.internal.org.xml.sax.Locator.getColumnNumber.

Return the column number where the current document event ends.

public ContentHandler

Returns:

The current content handler, or null if none has been registered.
getContentHandler
()

Implements jdk.internal.org.xml.sax.XMLReader.getContentHandler.

Return the current content handler.

public DTDHandler

Returns:

The current DTD handler, or null if none has been registered.
getDTDHandler
()

Implements jdk.internal.org.xml.sax.XMLReader.getDTDHandler.

Return the current DTD handler.

public EntityResolver

Returns:

The current entity resolver, or null if none has been registered.
getEntityResolver
()

Implements jdk.internal.org.xml.sax.XMLReader.getEntityResolver.

Return the current entity resolver.

public ErrorHandler

Returns:

The current error handler, or null if none has been registered.
getErrorHandler
()

Implements jdk.internal.org.xml.sax.XMLReader.getErrorHandler.

Return the current error handler.

public boolean
getFeature(String name)

Implements jdk.internal.org.xml.sax.XMLReader.getFeature.

Look up the value of a feature flag.

public int

Returns:

Always returns -1 indicating the line number is not available.
getLineNumber
()

Implements jdk.internal.org.xml.sax.Locator.getLineNumber.

Return the line number where the current document event ends.

public Object
getProperty(String name)

Implements jdk.internal.org.xml.sax.XMLReader.getProperty.

Look up the value of a property.

public String

Returns:

A string containing the public identifier, or null if none is available.
getPublicId
()

Implements jdk.internal.org.xml.sax.Locator.getPublicId.

Return the public identifier for the current document event.

public String

Returns:

A string containing the system identifier, or null if none is available.
getSystemId
()

Implements jdk.internal.org.xml.sax.Locator.getSystemId.

Return the system identifier for the current document event.

protected void
newPrefix()

Implements abstract jdk.internal.util.xml.impl.Parser.newPrefix.

Reports new namespace prefix.

protected void
notDecl(String
The notation's name.
name
,
String
The notation's public identifier, or null if none was given.
pubid
,
String
The notation's system identifier, or null if none was given.
sysid
)

Implements abstract jdk.internal.util.xml.impl.Parser.notDecl.

Reports notation declaration.

protected void
panic(String
The problem description message.
msg
)

Implements abstract jdk.internal.util.xml.impl.Parser.panic.

Notifies the handler about fatal parsing error.

public void
parse(String
The system identifier (URI).
systemId
)

Implements jdk.internal.org.xml.sax.XMLReader.parse.

Parse an XML document from a system identifier (URI).

public void
parse(InputSource
The input source for the top-level of the XML document.
is
)

Implements jdk.internal.org.xml.sax.XMLReader.parse.

Parse an XML document.

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

Parse the content of the given java.io.InputStream instance 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.
handler
)

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

private void
parse()

Parse the XML document content using specified handlers and an input source.

protected void
pi(String
The processing instruction target name.
target
,
String
The processing instruction body text.
body
)

Implements abstract jdk.internal.util.xml.impl.Parser.pi.

Reports a processing instruction.

protected InputSource
resolveEnt(String
The name of the entity.
name
,
String
The public identifier of the entity.
pubid
,
String
The system identifier of the entity.
sysid
)

Implements abstract jdk.internal.util.xml.impl.Parser.resolveEnt.

Returns an InputSource for specified entity or null.

public void
setContentHandler(ContentHandler
The content handler.
handler
)

Implements jdk.internal.org.xml.sax.XMLReader.setContentHandler.

Allow an application to register a content event handler.

public void
setDTDHandler(DTDHandler
The DTD handler.
handler
)

Implements jdk.internal.org.xml.sax.XMLReader.setDTDHandler.

Allow an application to register a DTD event handler.

public void
setEntityResolver(EntityResolver
The entity resolver.
resolver
)

Implements jdk.internal.org.xml.sax.XMLReader.setEntityResolver.

Allow an application to register an entity resolver.

public void
setErrorHandler(ErrorHandler
The error handler.
handler
)

Implements jdk.internal.org.xml.sax.XMLReader.setErrorHandler.

Allow an application to register an error event handler.

public void
setFeature(String name, boolean value)

Implements jdk.internal.org.xml.sax.XMLReader.setFeature.

Set the value of a feature flag.

public void
setProperty(String name, Object value)

Implements jdk.internal.org.xml.sax.XMLReader.setProperty.

Set the value of a property.

protected void
skippedEnt(String
The entity name.
name
)

Implements abstract jdk.internal.util.xml.impl.Parser.skippedEnt.

Reports skipped entity name.

public void
startInternalSub()

Implements abstract jdk.internal.util.xml.impl.Parser.startInternalSub.

Reports the start of DTD internal subset.

protected void
unparsedEntDecl(String
The unparsed entity's name.
name
,
String
The entity's public identifier, or null if none was given.
pubid
,
String
The entity's system identifier.
sysid
,
String
The name of the associated notation.
notation
)

Implements abstract jdk.internal.util.xml.impl.Parser.unparsedEntDecl.

Reports unparsed entity name.

Inherited from jdk.internal.util.xml.impl.Parser:
bkchchtypcleanupdeleqstrfindgetchinitnamepairpoppushqnamesetchsetinpstepwsskip

Field Detail

FEATURE_NSback to summary
public static final String FEATURE_NS
FEATURE_PREFback to summary
public static final String FEATURE_PREF
mFNamespacesback to summary
private boolean mFNamespaces
mFPrefixesback to summary
private boolean mFPrefixes
mHandback to summary
private DefaultHandler mHand
mHandContback to summary
private ContentHandler mHandCont
mHandDtdback to summary
private DTDHandler mHandDtd
mHandEntback to summary
private EntityResolver mHandEnt
mHandErrback to summary
private ErrorHandler mHandErr

Constructor Detail

ParserSAXback to summary
public ParserSAX()

Constructor.

Method Detail

bflashback to summary
protected void bflash() throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.bflash.

Reports characters and empties the parser's buffer. This method is called only if parser is going to return control to the main loop. This means that this method may use parser buffer to report white space without copying characters to temporary buffer.

bflash_wsback to summary
protected void bflash_ws() throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.bflash_ws.

Reports white space characters and empties the parser's buffer. This method is called only if parser is going to return control to the main loop. This means that this method may use parser buffer to report white space without copying characters to temporary buffer.

commback to summary
protected void comm(char[] text, int length)

Implements abstract jdk.internal.util.xml.impl.Parser.comm.

Reports a comment.

Parameters
text:char[]

The comment text starting from first character.

length:int

The number of characters in comment.

docTypeback to summary
protected void docType(String name, String pubid, String sysid) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.docType.

Reports document type.

Parameters
name:String

The name of the entity.

pubid:String

The public identifier of the entity or null.

sysid:String

The system identifier of the entity or null.

getColumnNumberback to summary
public int getColumnNumber()

Implements jdk.internal.org.xml.sax.Locator.getColumnNumber.

Return the column number where the current document event ends.

Returns:int

Always returns -1 indicating the column number is not available.

See Also
getLineNumber
getContentHandlerback to summary
public ContentHandler getContentHandler()

Implements jdk.internal.org.xml.sax.XMLReader.getContentHandler.

Return the current content handler.

Returns:ContentHandler

The current content handler, or null if none has been registered.

See Also
setContentHandler
getDTDHandlerback to summary
public DTDHandler getDTDHandler()

Implements jdk.internal.org.xml.sax.XMLReader.getDTDHandler.

Return the current DTD handler.

Returns:DTDHandler

The current DTD handler, or null if none has been registered.

See Also
setDTDHandler
getEntityResolverback to summary
public EntityResolver getEntityResolver()

Implements jdk.internal.org.xml.sax.XMLReader.getEntityResolver.

Return the current entity resolver.

Returns:EntityResolver

The current entity resolver, or null if none has been registered.

See Also
setEntityResolver
getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

Implements jdk.internal.org.xml.sax.XMLReader.getErrorHandler.

Return the current error handler.

Returns:ErrorHandler

The current error handler, or null if none has been registered.

See Also
setErrorHandler
getFeatureback to summary
public boolean getFeature(String name)

Implements jdk.internal.org.xml.sax.XMLReader.getFeature.

Doc from jdk.internal.org.xml.sax.XMLReader.getFeature.

Look up the value of a feature flag.

The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but temporarily be unable to return its value. Some feature values may be available only in specific contexts, such as before, during, or after a parse. Also, some feature values may not be programmatically accessible. (In the case of an adapter for SAX1 Parser, there is no implementation-independent way to expose whether the underlying parser is performing validation, expanding external entities, and so forth.)

All XMLReaders are required to recognize the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes feature names.

Typical usage is something like this:

XMLReader r = new MySAXDriver();

                        // try to activate validation
try {
  r.setFeature("http://xml.org/sax/features/validation", true);
} catch (SAXException e) {
  System.err.println("Cannot activate validation.");
}

                        // register event handlers
r.setContentHandler(new MyContentHandler());
r.setErrorHandler(new MyErrorHandler());

                        // parse the first document
try {
  r.parse("http://www.foo.com/mydoc.xml");
} catch (IOException e) {
  System.err.println("I/O exception reading XML document");
} catch (SAXException e) {
  System.err.println("XML exception reading document.");
}

Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.

getLineNumberback to summary
public int getLineNumber()

Implements jdk.internal.org.xml.sax.Locator.getLineNumber.

Return the line number where the current document event ends.

Returns:int

Always returns -1 indicating the line number is not available.

See Also
getColumnNumber
getPropertyback to summary
public Object getProperty(String name)

Implements jdk.internal.org.xml.sax.XMLReader.getProperty.

Doc from jdk.internal.org.xml.sax.XMLReader.getProperty.

Look up the value of a property.

The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but temporarily be unable to return its value. Some property values may be available only in specific contexts, such as before, during, or after a parse.

XMLReaders are not required to recognize any specific property names, though an initial core set is documented for SAX2.

Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs.

getPublicIdback to summary
public String getPublicId()

Implements jdk.internal.org.xml.sax.Locator.getPublicId.

Return the public identifier for the current document event.

The return value is the public identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

Returns:String

A string containing the public identifier, or null if none is available.

See Also
getSystemId
getSystemIdback to summary
public String getSystemId()

Implements jdk.internal.org.xml.sax.Locator.getSystemId.

Return the system identifier for the current document event.

The return value is the system identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Returns:String

A string containing the system identifier, or null if none is available.

See Also
getPublicId
newPrefixback to summary
protected void newPrefix() throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.newPrefix.

Reports new namespace prefix. The Namespace prefix ( mPref.name) being declared and the Namespace URI ( mPref.value) the prefix is mapped to. An empty string is used for the default element namespace, which has no prefix.

notDeclback to summary
protected void notDecl(String name, String pubid, String sysid) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.notDecl.

Reports notation declaration.

Parameters
name:String

The notation's name.

pubid:String

The notation's public identifier, or null if none was given.

sysid:String

The notation's system identifier, or null if none was given.

panicback to summary
protected void panic(String msg) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.panic.

Notifies the handler about fatal parsing error.

Parameters
msg:String

The problem description message.

parseback to summary
public void parse(String systemId) throws IOException, SAXException

Implements jdk.internal.org.xml.sax.XMLReader.parse.

Parse an XML document from a system identifier (URI).

This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:

parse(new InputSource(systemId));

If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.

Parameters
systemId:String

The system identifier (URI).

Exceptions
IOException:
An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
parse(org.xml.sax.InputSource)
parseback to summary
public void parse(InputSource is) throws IOException, SAXException

Implements jdk.internal.org.xml.sax.XMLReader.parse.

Parse an XML document.

The application can use this method to instruct the XML reader to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).

Applications may not invoke this method while a parse is in progress (they should create a new XMLReader instead for each nested XML document). Once a parse is complete, an application may reuse the same XMLReader object, possibly with a different input source.

During the parse, the XMLReader will provide information about the XML document through the registered event handlers.

This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.

Parameters
is:InputSource

The input source for the top-level of the XML document.

Exceptions
IOException:
An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
org.xml.sax.InputSource, parse(java.lang.String), setEntityResolver, setDTDHandler, setContentHandler, setErrorHandler
parseback to summary
public void parse(InputStream src, DefaultHandler handler) throws SAXException, IOException

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

Parameters
src:InputStream

InputStream containing the content to be parsed.

handler:DefaultHandler

The SAX DefaultHandler to use.

Exceptions
SAXException:
If the underlying parser throws a SAXException while parsing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the given InputStream or handler is null.
See Also
org.xml.sax.helpers.DefaultHandler
parseback to summary
public void parse(InputSource is, DefaultHandler handler) 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.

handler:DefaultHandler

The SAX DefaultHandler to use.

Exceptions
SAXException:
If the underlying parser throws a SAXException while parsing.
IOException:
If any IO errors occur.
IllegalArgumentException:
If the InputSource or handler is null.
See Also
org.xml.sax.helpers.DefaultHandler
parseback to summary
private void parse() throws SAXException, IOException

Parse the XML document content using specified handlers and an input source.

Annotations
@SuppressWarnings:fallthrough
Exceptions
SAXException:
If the underlying parser throws a SAXException while parsing.
IOException:
If any IO errors occur.
piback to summary
protected void pi(String target, String body) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.pi.

Reports a processing instruction.

Parameters
target:String

The processing instruction target name.

body:String

The processing instruction body text.

resolveEntback to summary
protected InputSource resolveEnt(String name, String pubid, String sysid) throws SAXException, IOException

Implements abstract jdk.internal.util.xml.impl.Parser.resolveEnt.

Returns an InputSource for specified entity or null.

Parameters
name:String

The name of the entity.

pubid:String

The public identifier of the entity.

sysid:String

The system identifier of the entity.

setContentHandlerback to summary
public void setContentHandler(ContentHandler handler)

Implements jdk.internal.org.xml.sax.XMLReader.setContentHandler.

Allow an application to register a content event handler.

If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters
handler:ContentHandler

The content handler.

Exceptions
NullPointerException:
If the handler argument is null.
See Also
getContentHandler
setDTDHandlerback to summary
public void setDTDHandler(DTDHandler handler)

Implements jdk.internal.org.xml.sax.XMLReader.setDTDHandler.

Allow an application to register a DTD event handler.

If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters
handler:DTDHandler

The DTD handler.

Exceptions
NullPointerException:
If the handler argument is null.
See Also
getDTDHandler
setEntityResolverback to summary
public void setEntityResolver(EntityResolver resolver)

Implements jdk.internal.org.xml.sax.XMLReader.setEntityResolver.

Allow an application to register an entity resolver.

If the application does not register an entity resolver, the XMLReader will perform its own default resolution.

Applications may register a new or different resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.

Parameters
resolver:EntityResolver

The entity resolver.

Exceptions
NullPointerException:
If the resolver argument is null.
See Also
getEntityResolver
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler handler)

Implements jdk.internal.org.xml.sax.XMLReader.setErrorHandler.

Allow an application to register an error event handler.

If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters
handler:ErrorHandler

The error handler.

Exceptions
NullPointerException:
If the handler argument is null.
See Also
getErrorHandler
setFeatureback to summary
public void setFeature(String name, boolean value)

Implements jdk.internal.org.xml.sax.XMLReader.setFeature.

Doc from jdk.internal.org.xml.sax.XMLReader.setFeature.

Set the value of a feature flag.

The feature name is any fully-qualified URI. It is possible for an XMLReader to expose a feature value but to be unable to change the current value. Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.

All XMLReaders are required to support setting http://xml.org/sax/features/namespaces to true and http://xml.org/sax/features/namespace-prefixes to false.

setPropertyback to summary
public void setProperty(String name, Object value)

Implements jdk.internal.org.xml.sax.XMLReader.setProperty.

Doc from jdk.internal.org.xml.sax.XMLReader.setProperty.

Set the value of a property.

The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to change the current value. Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.

XMLReaders are not required to recognize setting any specific property names, though a core set is defined by SAX2.

This method is also the standard mechanism for setting extended handlers.

skippedEntback to summary
protected void skippedEnt(String name) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.skippedEnt.

Reports skipped entity name.

Parameters
name:String

The entity name.

startInternalSubback to summary
public void startInternalSub() throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.startInternalSub.

Reports the start of DTD internal subset.

Exceptions
SAXException:
if the receiver throws SAXException
unparsedEntDeclback to summary
protected void unparsedEntDecl(String name, String pubid, String sysid, String notation) throws SAXException

Implements abstract jdk.internal.util.xml.impl.Parser.unparsedEntDecl.

Reports unparsed entity name.

Parameters
name:String

The unparsed entity's name.

pubid:String

The entity's public identifier, or null if none was given.

sysid:String

The entity's system identifier.

notation:String

The name of the associated notation.