APIdia Launch Partner
Top Description Inners Fields Constructors Methods
org.xml.sax.helpers

public Class XMLReaderAdapter

extends Object
implements Parser, ContentHandler
Class Inheritance
All Implemented Interfaces
org.xml.sax.ContentHandler, org.xml.sax.Parser
Annotations
@SuppressWarnings:deprecation
Imports
java.io.IOException, java.util.Locale, org.xml.sax.Parser, .Locator, .InputSource, .AttributeList, .EntityResolver, .DTDHandler, .DocumentHandler, .ErrorHandler, .SAXException, .XMLReader, .Attributes, .ContentHandler, .SAXNotSupportedException

References Deprecated

Parser is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Adapt a SAX2 XMLReader as a SAX1 Parser.

This class wraps a SAX2 XMLReader and makes it act as a SAX1 Parser. The XMLReader must support a true value for the http://xml.org/sax/features/namespace-prefixes property or parsing will fail with a SAXException; if the XMLReader supports a false value for the http://xml.org/sax/features/namespaces property, that will also be used to improve efficiency.

Author
David Megginson
Since
1.4, SAX 2.0
See Also
org.xml.sax.Parser, org.xml.sax.XMLReader

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
XMLReaderAdapter.AttributesAdapter

References Deprecated AttributeList is deprecated or references (maybe indirectly) at least one deprecated element.
Internal class to wrap a SAX2 Attributes object for SAX1.

Field Summary

Modifier and TypeField and Description
pack-priv DocumentHandler
documentHandler

References Deprecated DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.
pack-priv XMLReaderAdapter.AttributesAdapter
qAtts

References Deprecated XMLReaderAdapter.AttributesAdapter is deprecated or references (maybe indirectly) at least one deprecated element.
pack-priv XMLReader

Constructor Summary

AccessConstructor and Description
public
XMLReaderAdapter()

Create a new adapter.

public
XMLReaderAdapter(XMLReader
The SAX2 XMLReader to wrap.
xmlReader
)

Create a new adapter.

Method Summary

Modifier and TypeMethod and Description
public void
characters(char[]
An array of characters.
ch
,
int
The starting position in the array.
start
,
int
The number of characters to use.
length
)

Implements org.xml.sax.ContentHandler.characters.

Adapt a SAX2 characters event.

public void
endDocument()

Implements org.xml.sax.ContentHandler.endDocument.

End document event.

public void
endElement(String
The Namespace URI.
uri
,
String
The Namespace local name.
localName
,
String
The qualified (prefixed) name.
qName
)

Implements org.xml.sax.ContentHandler.endElement.

Adapt a SAX2 end element event.

public void
endPrefixMapping(String
The prefix being mapped.
prefix
)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Adapt a SAX2 end prefix mapping event.

public void
ignorableWhitespace(char[]
An array of characters.
ch
,
int
The starting position in the array.
start
,
int
The number of characters to use.
length
)

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Adapt a SAX2 ignorable whitespace event.

public void
parse(String
The absolute URL of the document.
systemId
)

Implements org.xml.sax.Parser.parse.

Parse the document.

public void
parse(InputSource
An input source for the document.
input
)

Implements org.xml.sax.Parser.parse.

Parse the document.

public void
processingInstruction(String
The processing instruction target.
target
,
String
The remainder of the processing instruction
data
)

Implements org.xml.sax.ContentHandler.processingInstruction.

Adapt a SAX2 processing instruction event.

public void
setDocumentHandler(DocumentHandler
The new SAX1 document event handler.
handler
)

Implements org.xml.sax.Parser.setDocumentHandler.

References Deprecated DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.

Register the SAX1 document event handler.

public void
setDocumentLocator(Locator
The document locator.
locator
)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Set a document locator.

public void
setDTDHandler(DTDHandler
The new DTD event handler.
handler
)

Implements org.xml.sax.Parser.setDTDHandler.

Register the DTD event handler.

public void
setEntityResolver(EntityResolver
The new resolver.
resolver
)

Implements org.xml.sax.Parser.setEntityResolver.

Register the entity resolver.

public void
setErrorHandler(ErrorHandler
The new error event handler.
handler
)

Implements org.xml.sax.Parser.setErrorHandler.

Register the error event handler.

public void
setLocale(Locale
the locale for error reporting.
locale
)

Implements org.xml.sax.Parser.setLocale.

Set the locale for error reporting.

private void
setup(XMLReader
The embedded XMLReader.
xmlReader
)

Internal setup.

private void
setupXMLReader()

Set up the XML reader.

public void
skippedEntity(String
The name of the skipped entity.
name
)

Implements org.xml.sax.ContentHandler.skippedEntity.

Adapt a SAX2 skipped entity event.

public void
startDocument()

Implements org.xml.sax.ContentHandler.startDocument.

Start document event.

public void
startElement(String
The Namespace URI.
uri
,
String
The Namespace local name.
localName
,
String
The qualified (prefixed) name.
qName
,
Attributes
The SAX2 attributes.
atts
)

Implements org.xml.sax.ContentHandler.startElement.

Adapt a SAX2 start element event.

public void
startPrefixMapping(String
The prefix being mapped.
prefix
,
String
The Namespace URI being mapped to.
uri
)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Adapt a SAX2 start prefix mapping event.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

documentHandlerback to summary
pack-priv DocumentHandler documentHandler

References Deprecated

DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

qAttsback to summary
pack-priv XMLReaderAdapter.AttributesAdapter qAtts

References Deprecated

XMLReaderAdapter.AttributesAdapter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

xmlReaderback to summary
pack-priv XMLReader xmlReader

Constructor Detail

XMLReaderAdapterback to summary
public XMLReaderAdapter() throws SAXException

Create a new adapter.

Use the "org.xml.sax.driver" property to locate the SAX2 driver to embed.

Exceptions
SAXException:
If the embedded driver cannot be instantiated or if the org.xml.sax.driver property is not specified.
XMLReaderAdapterback to summary
public XMLReaderAdapter(XMLReader xmlReader)

Create a new adapter.

Create a new adapter, wrapped around a SAX2 XMLReader. The adapter will make the XMLReader act like a SAX1 Parser.

Parameters
xmlReader:XMLReader

The SAX2 XMLReader to wrap.

Exceptions
NullPointerException:
If the argument is null.

Method Detail

charactersback to summary
public void characters(char[] ch, int start, int length) throws SAXException

Implements org.xml.sax.ContentHandler.characters.

Adapt a SAX2 characters event.

Parameters
ch:char[]

An array of characters.

start:int

The starting position in the array.

length:int

The number of characters to use.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#characters
endDocumentback to summary
public void endDocument() throws SAXException

Implements org.xml.sax.ContentHandler.endDocument.

End document event.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#endDocument
endElementback to summary
public void endElement(String uri, String localName, String qName) throws SAXException

Implements org.xml.sax.ContentHandler.endElement.

Adapt a SAX2 end element event.

Parameters
uri:String

The Namespace URI.

localName:String

The Namespace local name.

qName:String

The qualified (prefixed) name.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#endElement
endPrefixMappingback to summary
public void endPrefixMapping(String prefix)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Adapt a SAX2 end prefix mapping event.

Parameters
prefix:String

The prefix being mapped.

See Also
org.xml.sax.ContentHandler#endPrefixMapping
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Adapt a SAX2 ignorable whitespace event.

Parameters
ch:char[]

An array of characters.

start:int

The starting position in the array.

length:int

The number of characters to use.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#ignorableWhitespace
parseback to summary
public void parse(String systemId) throws IOException, SAXException

Implements org.xml.sax.Parser.parse.

Parse the document.

This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.

Parameters
systemId:String

The absolute URL of the document.

Exceptions
IOException:
If there is a problem reading the raw content of the document.
SAXException:
If there is a problem processing the document.
See Also
parse(org.xml.sax.InputSource), org.xml.sax.Parser#parse(java.lang.String)
parseback to summary
public void parse(InputSource input) throws IOException, SAXException

Implements org.xml.sax.Parser.parse.

Parse the document.

This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.

Parameters
input:InputSource

An input source for the document.

Exceptions
IOException:
If there is a problem reading the raw content of the document.
SAXException:
If there is a problem processing the document.
See Also
parse(java.lang.String), org.xml.sax.Parser#parse(org.xml.sax.InputSource)
processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Implements org.xml.sax.ContentHandler.processingInstruction.

Adapt a SAX2 processing instruction event.

Parameters
target:String

The processing instruction target.

data:String

The remainder of the processing instruction

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#processingInstruction
setDocumentHandlerback to summary
public void setDocumentHandler(DocumentHandler handler)

Implements org.xml.sax.Parser.setDocumentHandler.

References Deprecated

DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Register the SAX1 document event handler.

Note that the SAX1 document handler has no Namespace support.

Parameters
handler:DocumentHandler

The new SAX1 document event handler.

See Also
org.xml.sax.Parser#setDocumentHandler
setDocumentLocatorback to summary
public void setDocumentLocator(Locator locator)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Set a document locator.

Parameters
locator:Locator

The document locator.

See Also
org.xml.sax.ContentHandler#setDocumentLocator
setDTDHandlerback to summary
public void setDTDHandler(DTDHandler handler)

Implements org.xml.sax.Parser.setDTDHandler.

Register the DTD event handler.

Parameters
handler:DTDHandler

The new DTD event handler.

See Also
org.xml.sax.Parser#setDTDHandler
setEntityResolverback to summary
public void setEntityResolver(EntityResolver resolver)

Implements org.xml.sax.Parser.setEntityResolver.

Register the entity resolver.

Parameters
resolver:EntityResolver

The new resolver.

See Also
org.xml.sax.Parser#setEntityResolver
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler handler)

Implements org.xml.sax.Parser.setErrorHandler.

Register the error event handler.

Parameters
handler:ErrorHandler

The new error event handler.

See Also
org.xml.sax.Parser#setErrorHandler
setLocaleback to summary
public void setLocale(Locale locale) throws SAXException

Implements org.xml.sax.Parser.setLocale.

Set the locale for error reporting.

This is not supported in SAX2, and will always throw an exception.

Parameters
locale:Locale

the locale for error reporting.

Exceptions
SAXException:
Thrown unless overridden.
See Also
org.xml.sax.Parser#setLocale
setupback to summary
private void setup(XMLReader xmlReader)

Internal setup.

Parameters
xmlReader:XMLReader

The embedded XMLReader.

setupXMLReaderback to summary
private void setupXMLReader() throws SAXException

Set up the XML reader.

skippedEntityback to summary
public void skippedEntity(String name) throws SAXException

Implements org.xml.sax.ContentHandler.skippedEntity.

Adapt a SAX2 skipped entity event.

Parameters
name:String

The name of the skipped entity.

Exceptions
SAXException:
Throwable by subclasses.
See Also
org.xml.sax.ContentHandler#skippedEntity
startDocumentback to summary
public void startDocument() throws SAXException

Implements org.xml.sax.ContentHandler.startDocument.

Start document event.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#startDocument
startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException

Implements org.xml.sax.ContentHandler.startElement.

Adapt a SAX2 start element event.

Parameters
uri:String

The Namespace URI.

localName:String

The Namespace local name.

qName:String

The qualified (prefixed) name.

atts:Attributes

The SAX2 attributes.

Exceptions
SAXException:
The client may raise a processing exception.
See Also
org.xml.sax.ContentHandler#endDocument
startPrefixMappingback to summary
public void startPrefixMapping(String prefix, String uri)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Adapt a SAX2 start prefix mapping event.

Parameters
prefix:String

The prefix being mapped.

uri:String

The Namespace URI being mapped to.

See Also
org.xml.sax.ContentHandler#startPrefixMapping
org.xml.sax.helpers back to summary

pack-priv final Class XMLReaderAdapter.AttributesAdapter

extends Object
implements AttributeList
Class Inheritance
All Implemented Interfaces
org.xml.sax.AttributeList

References Deprecated

AttributeList is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Internal class to wrap a SAX2 Attributes object for SAX1.

Field Summary

Modifier and TypeField and Description
private Attributes

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The length of the attribute list.
getLength
()

Implements org.xml.sax.AttributeList.getLength.

Return the number of attributes.

public String

Returns:

The qualified name.
getName
(int i)

Implements org.xml.sax.AttributeList.getName.

Return the qualified (prefixed) name of an attribute by position.

public String

Returns:

The type.
getType
(int i)

Implements org.xml.sax.AttributeList.getType.

Return the type of an attribute by position.

public String

Returns:

The type.
getType
(String qName)

Implements org.xml.sax.AttributeList.getType.

Return the type of an attribute by qualified (prefixed) name.

public String

Returns:

The value.
getValue
(int i)

Implements org.xml.sax.AttributeList.getValue.

Return the value of an attribute by position.

public String

Returns:

The value.
getValue
(String qName)

Implements org.xml.sax.AttributeList.getValue.

Return the value of an attribute by qualified (prefixed) name.

pack-priv void
setAttributes(Attributes attributes)

Set the embedded Attributes object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private Attributes attributes

Constructor Detail

AttributesAdapterback to summary
pack-priv AttributesAdapter()

Method Detail

getLengthback to summary
public int getLength()

Implements org.xml.sax.AttributeList.getLength.

Return the number of attributes.

Returns:int

The length of the attribute list.

See Also
org.xml.sax.AttributeList#getLength
getNameback to summary
public String getName(int i)

Implements org.xml.sax.AttributeList.getName.

Return the qualified (prefixed) name of an attribute by position.

Returns:String

The qualified name.

See Also
org.xml.sax.AttributeList#getName
getTypeback to summary
public String getType(int i)

Implements org.xml.sax.AttributeList.getType.

Return the type of an attribute by position.

Returns:String

The type.

See Also
org.xml.sax.AttributeList#getType(int)
getTypeback to summary
public String getType(String qName)

Implements org.xml.sax.AttributeList.getType.

Return the type of an attribute by qualified (prefixed) name.

Returns:String

The type.

See Also
org.xml.sax.AttributeList#getType(java.lang.String)
getValueback to summary
public String getValue(int i)

Implements org.xml.sax.AttributeList.getValue.

Return the value of an attribute by position.

Returns:String

The value.

See Also
org.xml.sax.AttributeList#getValue(int)
getValueback to summary
public String getValue(String qName)

Implements org.xml.sax.AttributeList.getValue.

Return the value of an attribute by qualified (prefixed) name.

Returns:String

The value.

See Also
org.xml.sax.AttributeList#getValue(java.lang.String)
setAttributesback to summary
pack-priv void setAttributes(Attributes attributes)

Set the embedded Attributes object.