public final class SAXDriver extends Object implements Locator, Attributes, XMLReader, Parser, AttributeList
Name | Notes |
---|---|
(URL)/external-general-entities | Value is fixed at true |
(URL)/external-parameter-entities | Value is fixed at true |
(URL)/namespace-prefixes | Value defaults to false (but XML 1.0 names are always reported) |
(URL)/namespaces | Value defaults to true |
(URL)/string-interning | Value is fixed at true |
(URL)/validation | Value is fixed at false |
(URL)/declaration-handler | A declaration handler may be provided. Declaration of general entities is exposed, but not parameter entities; none of the entity names reported here will begin with "%". |
(URL)/lexical-handler | A lexical handler may be provided. Entity boundaries and comments are not exposed; only CDATA sections and the start/end of the DTD (the internal subset is not detectible). |
Note that the declaration handler doesn't suffice for showing all the logical structure of the DTD; it doesn't expose the name of the root element, or the values that are permitted in a NOTATIONS attribute. (The former is exposed as lexical data, and SAX2 beta doesn't expose the latter.)
Although support for several features and properties is "built in" to this parser, it support all others by storing the assigned values and returning them.
This parser currently implements the SAX1 Parser API, but it may not continue to do so in the future.
Parser
Modifier and Type | Class and Description |
---|---|
private static class |
SAXDriver.Adapter |
Modifier and Type | Field and Description |
---|---|
private int |
attributeCount |
private ArrayList |
attributeLocalNames |
private ArrayList |
attributeNames |
private ArrayList |
attributeNamespaces |
private ArrayList |
attributeValues |
private DefaultHandler |
base |
private ContentHandler |
contentHandler |
private DeclHandler |
declHandler |
private DTDHandler |
dtdHandler |
private String |
elementName |
private EntityResolver |
entityResolver |
private ArrayList |
entityStack |
private ErrorHandler |
errorHandler |
(package private) static String |
FEATURE |
private HashMap |
features |
(package private) static String |
HANDLER |
private LexicalHandler |
lexicalHandler |
private boolean |
namespaces |
private boolean |
nspending |
private String[] |
nsTemp |
private XmlParser |
parser |
private NamespaceSupport |
prefixStack |
private HashMap |
properties |
private boolean |
xmlNames |
Constructor and Description |
---|
SAXDriver()
Constructs a SAX Parser.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
attribute(String aname,
String value,
boolean isSpecified) |
(package private) void |
charData(char[] ch,
int start,
int length) |
(package private) void |
comment(char[] ch,
int start,
int length) |
private void |
deliverDTDEvents() |
(package private) void |
doctypeDecl(String name,
String publicId,
String systemId) |
(package private) void |
endCDATA() |
(package private) void |
endDoctype() |
(package private) void |
endDocument() |
(package private) void |
endElement(String elname) |
(package private) void |
endExternalEntity(String systemId) |
(package private) void |
error(String message,
String url,
int line,
int column) |
int |
getColumnNumber()
SAX Locator method (don't invoke on parser);
|
ContentHandler |
getContentHandler()
SAX2: Returns the object used to report the logical
content of an XML document.
|
DTDHandler |
getDTDHandler()
SAX2: Returns the object used to process declarations related
to notations and unparsed entities.
|
EntityResolver |
getEntityResolver()
SAX2: Returns the object used when resolving external
entities during parsing (both general and parameter entities).
|
ErrorHandler |
getErrorHandler()
SAX2: Returns the object used to receive callbacks for XML
errors of all levels (fatal, nonfatal, warning); this is never null;
|
boolean |
getFeature(String featureId)
SAX2: Tells the value of the specified feature flag.
|
int |
getIndex(String xmlName)
SAX2 Attributes method (don't invoke on parser);
|
int |
getIndex(String uri,
String local)
SAX2 Attributes method (don't invoke on parser);
|
int |
getLength()
SAX1 AttributeList, SAX2 Attributes method
(don't invoke on parser);
|
int |
getLineNumber()
SAX Locator method (don't invoke on parser);
|
String |
getLocalName(int index)
SAX2 Attributes method (don't invoke on parser);
|
String |
getName(int i)
SAX1 AttributeList method (don't invoke on parser);
|
Object |
getProperty(String propertyId)
SAX2: Returns the specified property.
|
String |
getPublicId()
SAX Locator method (don't invoke on parser);
|
String |
getQName(int i)
SAX2 Attributes method (don't invoke on parser);
|
String |
getSystemId()
SAX Locator method (don't invoke on parser);
|
String |
getType(int i)
SAX1 AttributeList, SAX2 Attributes method
(don't invoke on parser);
|
String |
getType(String xmlName)
SAX1 AttributeList, SAX2 Attributes method
(don't invoke on parser);
|
String |
getType(String uri,
String local)
SAX2 Attributes method (don't invoke on parser);
|
String |
getURI(int index)
SAX2 Attributes method (don't invoke on parser);
|
String |
getValue(int i)
SAX1 AttributeList, SAX2 Attributes method
(don't invoke on parser);
|
String |
getValue(String xmlName)
SAX1 AttributeList, SAX2 Attributes method
(don't invoke on parser);
|
String |
getValue(String uri,
String local)
SAX Attributes method (don't invoke on parser);
|
(package private) void |
ignorableWhitespace(char[] ch,
int start,
int length) |
void |
parse(InputSource source)
SAX1, SAX2: Auxiliary API to parse an XML document, used mostly
when no URI is available.
|
void |
parse(String systemId)
SAX1, SAX2: Preferred API to parse an XML document, using a
system identifier (URI).
|
(package private) void |
processingInstruction(String target,
String data) |
(package private) Object |
resolveEntity(String publicId,
String systemId) |
void |
setContentHandler(ContentHandler handler)
SAX2: Assigns the object used to report the logical
content of an XML document.
|
void |
setDocumentHandler(DocumentHandler handler)
Deprecated.
SAX2 programs should use the XMLReader interface
and a ContentHandler.
|
void |
setDTDHandler(DTDHandler handler)
SAX1, SAX2: Set the DTD handler for this parser.
|
void |
setEntityResolver(EntityResolver resolver)
SAX1, SAX2: Set the entity resolver for this parser.
|
void |
setErrorHandler(ErrorHandler handler)
SAX1, SAX2: Set the error handler for this parser.
|
void |
setFeature(String featureId,
boolean state)
SAX2: Sets the state of feature flags in this parser.
|
void |
setLocale(Locale locale)
SAX1: Sets the locale used for diagnostics; currently,
only locales using the English language are supported.
|
void |
setProperty(String propertyId,
Object property)
SAX2: Assigns the specified property.
|
(package private) void |
startCDATA() |
(package private) void |
startDocument() |
(package private) void |
startElement(String elname) |
(package private) void |
startExternalEntity(String systemId) |
private final DefaultHandler base
private EntityResolver entityResolver
private ContentHandler contentHandler
private DTDHandler dtdHandler
private ErrorHandler errorHandler
private DeclHandler declHandler
private LexicalHandler lexicalHandler
private String elementName
private ArrayList entityStack
private ArrayList attributeNames
private ArrayList attributeNamespaces
private ArrayList attributeLocalNames
private ArrayList attributeValues
private boolean namespaces
private boolean xmlNames
private boolean nspending
private int attributeCount
private NamespaceSupport prefixStack
private HashMap properties
static final String FEATURE
static final String HANDLER
public SAXDriver()
public void setLocale(Locale locale) throws SAXException
setLocale
in interface Parser
locale
- The locale for which diagnostics will be generatedSAXException
- Throws an exception
(using the previous or default locale) if the
requested locale is not supported.SAXException
,
SAXParseException
public EntityResolver getEntityResolver()
getEntityResolver
in interface XMLReader
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public void setEntityResolver(EntityResolver resolver)
setEntityResolver
in interface Parser
setEntityResolver
in interface XMLReader
handler
- The object to receive entity events.XMLReader.getEntityResolver()
public DTDHandler getDTDHandler()
getDTDHandler
in interface XMLReader
XMLReader.setDTDHandler(org.xml.sax.DTDHandler)
public void setDTDHandler(DTDHandler handler)
setDTDHandler
in interface Parser
setDTDHandler
in interface XMLReader
handler
- The object to receive DTD events.XMLReader.getDTDHandler()
public void setDocumentHandler(DocumentHandler handler)
setDocumentHandler
in interface Parser
handler
- The object to receive document events.DocumentHandler
,
HandlerBase
public ContentHandler getContentHandler()
getContentHandler
in interface XMLReader
XMLReader.setContentHandler(org.xml.sax.ContentHandler)
public void setContentHandler(ContentHandler handler)
setContentHandler
in interface XMLReader
handler
- The content handler.XMLReader.getContentHandler()
public void setErrorHandler(ErrorHandler handler)
setErrorHandler
in interface Parser
setErrorHandler
in interface XMLReader
handler
- The object to receive error events.XMLReader.getErrorHandler()
public ErrorHandler getErrorHandler()
getErrorHandler
in interface XMLReader
XMLReader.setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(InputSource source) throws SAXException, IOException
parse
in interface Parser
parse
in interface XMLReader
source
- The XML input source. Don't set 'encoding' unless
you know for a fact that it's correct.SAXException
- The handlers may throw any SAXException,
and the parser normally throws SAXParseException objects.IOException
- IOExceptions are normally through through
the parser if there are problems reading the source document.setEntityResolver(org.xml.sax.EntityResolver)
,
setDTDHandler(org.xml.sax.DTDHandler)
,
setContentHandler(org.xml.sax.ContentHandler)
,
setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(String systemId) throws SAXException, IOException
parse
in interface Parser
parse
in interface XMLReader
systemId
- The system identifier (URI).SAXException
- Any SAX exception, possibly
wrapping another exception.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.XMLReader.parse(org.xml.sax.InputSource)
public boolean getFeature(String featureId) throws SAXNotRecognizedException
getFeature
in interface XMLReader
featureId
- The feature name, which is a fully-qualified URI.SAXNotRecognizedException
- thrown if the feature flag
is neither built in, nor yet assigned.XMLReader.setFeature(java.lang.String, boolean)
public Object getProperty(String propertyId) throws SAXNotRecognizedException
getProperty
in interface XMLReader
propertyId
- The property name, which is a fully-qualified URI.SAXNotRecognizedException
- thrown if the property value
is neither built in, nor yet stored.XMLReader.setProperty(java.lang.String, java.lang.Object)
public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException
setFeature
in interface XMLReader
featureId
- The feature name, which is a fully-qualified URI.SAXNotRecognizedException
- When the
XMLReader does not recognize the feature name.SAXNotSupportedException
- When the
XMLReader recognizes the feature name but
cannot set the requested value.XMLReader.getFeature(java.lang.String)
public void setProperty(String propertyId, Object property) throws SAXNotRecognizedException, SAXNotSupportedException
setProperty
in interface XMLReader
propertyId
- The property name, which is a fully-qualified URI.SAXNotRecognizedException
- When the
XMLReader does not recognize the property name.SAXNotSupportedException
- When the
XMLReader recognizes the property name but
cannot set the requested value.void startDocument() throws SAXException
SAXException
void endDocument() throws SAXException
SAXException
Object resolveEntity(String publicId, String systemId) throws SAXException, IOException
SAXException
IOException
void startExternalEntity(String systemId) throws SAXException
SAXException
void endExternalEntity(String systemId) throws SAXException
SAXException
void doctypeDecl(String name, String publicId, String systemId) throws SAXException
SAXException
void endDoctype() throws SAXException
SAXException
void attribute(String aname, String value, boolean isSpecified) throws SAXException
SAXException
void startElement(String elname) throws SAXException
SAXException
void endElement(String elname) throws SAXException
SAXException
void startCDATA() throws SAXException
SAXException
void charData(char[] ch, int start, int length) throws SAXException
SAXException
void endCDATA() throws SAXException
SAXException
void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
SAXException
void processingInstruction(String target, String data) throws SAXException
SAXException
void comment(char[] ch, int start, int length) throws SAXException
SAXException
void error(String message, String url, int line, int column) throws SAXException
SAXException
private void deliverDTDEvents() throws SAXException
SAXException
public int getLength()
getLength
in interface AttributeList
getLength
in interface Attributes
Attributes.getURI(int)
,
Attributes.getLocalName(int)
,
Attributes.getQName(int)
,
Attributes.getType(int)
,
Attributes.getValue(int)
public String getURI(int index)
getURI
in interface Attributes
index
- The attribute index (zero-based).Attributes.getLength()
public String getLocalName(int index)
getLocalName
in interface Attributes
index
- The attribute index (zero-based).Attributes.getLength()
public String getQName(int i)
getQName
in interface Attributes
i
- The attribute index (zero-based).Attributes.getLength()
public String getName(int i)
getName
in interface AttributeList
i
- The index of the attribute in the list (starting at 0).AttributeList.getLength()
public String getType(int i)
getType
in interface AttributeList
getType
in interface Attributes
i
- The attribute index (zero-based).Attributes.getLength()
public String getValue(int i)
getValue
in interface AttributeList
getValue
in interface Attributes
i
- The attribute index (zero-based).Attributes.getLength()
public int getIndex(String uri, String local)
getIndex
in interface Attributes
uri
- The Namespace URI, or the empty string if
the name has no Namespace URI.public int getIndex(String xmlName)
getIndex
in interface Attributes
xmlName
- The qualified (prefixed) name.public String getType(String uri, String local)
getType
in interface Attributes
uri
- The Namespace URI, or the empty String if the
name has no Namespace URI.local
- The local name of the attribute.public String getType(String xmlName)
getType
in interface AttributeList
getType
in interface Attributes
xmlName
- The XML 1.0 qualified name.AttributeList.getType(int)
public String getValue(String uri, String local)
getValue
in interface Attributes
uri
- The Namespace URI, or the empty String if the
name has no Namespace URI.local
- The local name of the attribute.public String getValue(String xmlName)
getValue
in interface AttributeList
getValue
in interface Attributes
xmlName
- The XML 1.0 qualified name.AttributeList.getValue(int)
public String getPublicId()
getPublicId
in interface Locator
Locator.getSystemId()
public String getSystemId()
getSystemId
in interface Locator
Locator.getPublicId()
public int getLineNumber()
getLineNumber
in interface Locator
Locator.getColumnNumber()
public int getColumnNumber()
getColumnNumber
in interface Locator
Locator.getLineNumber()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses