gnu.xml.aelfred2

Class SAXDriver

Implemented Interfaces:
AttributeList, Attributes, Attributes2, Locator, Parser, XMLReader

public final class SAXDriver
extends Object
implements Locator, Attributes2, XMLReader, Parser, AttributeList

An enhanced SAX2 version of Microstar's Ælfred XML parser. The enhancements primarily relate to significant improvements in conformance to the XML specification, and SAX2 support. Performance has been improved. See the package level documentation for more information.
NameNotes
Features ... URL prefix is http://xml.org/sax/features/
(URL)/external-general-entitiesValue defaults to true
(URL)/external-parameter-entitiesValue defaults to true
(URL)/is-standalone(PRELIMINARY) Returns true iff the document's parsing has started (some non-error event after startDocument() was reported) and the document's standalone flag is set.
(URL)/namespace-prefixesValue defaults to false (but XML 1.0 names are always reported)
(URL)/lexical-handler/parameter-entitiesValue is fixed at true
(URL)/namespacesValue defaults to true
(URL)/resolve-dtd-uris(PRELIMINARY) Value defaults to true
(URL)/string-interningValue is fixed at true
(URL)/use-attributes2(PRELIMINARY) Value is fixed at true
(URL)/use-entity-resolver2(PRELIMINARY) Value defaults to true
(URL)/validationValue is fixed at false
Handler Properties ... URL prefix is http://xml.org/sax/properties/
(URL)/declaration-handlerA declaration handler may be provided.
(URL)/lexical-handlerA lexical handler may be provided.

This parser currently implements the SAX1 Parser API, but it may not continue to do so in the future.

See Also:
Parser

Constructor Summary

SAXDriver()
Constructs a SAX Parser.

Method Summary

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 index)
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 index)
SAX2 Attributes method (don't invoke on parser);
String
getSystemId()
SAX Locator method (don't invoke on parser);
String
getType(int index)
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 index)
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);
boolean
isDeclared(int index)
boolean
isDeclared(String qName)
boolean
isDeclared(String uri, String localName)
boolean
isSpecified(int index)
SAX-ext Attributes2 method (don't invoke on parser);
boolean
isSpecified(String xmlName)
SAX-ext Attributes2 method (don't invoke on parser);
boolean
isSpecified(String uri, String local)
SAX-ext Attributes2 method (don't invoke on parser);
void
parse(String systemId)
SAX1, SAX2: Preferred API to parse an XML document, using a system identifier (URI).
void
parse(InputSource source)
SAX1, SAX2: Auxiliary API to parse an XML document, used mostly when no URI is available.
void
setContentHandler(ContentHandler handler)
SAX2: Assigns the object used to report the logical content of an XML document.
void
setDTDHandler(DTDHandler handler)
SAX1, SAX2: Set the DTD handler for this parser.
void
setDocumentHandler(DocumentHandler handler)
Deprecated. SAX2 programs should use the XMLReader interface and a ContentHandler.
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 value)
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 value)
SAX2: Assigns the specified property.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

SAXDriver

public SAXDriver()
Constructs a SAX Parser.

Method Details

getColumnNumber

public int getColumnNumber()
SAX Locator method (don't invoke on parser);
Specified by:
getColumnNumber in interface Locator

getContentHandler

public ContentHandler getContentHandler()
SAX2: Returns the object used to report the logical content of an XML document.
Specified by:
getContentHandler in interface XMLReader

getDTDHandler

public DTDHandler getDTDHandler()
SAX2: Returns the object used to process declarations related to notations and unparsed entities.
Specified by:
getDTDHandler in interface XMLReader

getEntityResolver

public EntityResolver getEntityResolver()
SAX2: Returns the object used when resolving external entities during parsing (both general and parameter entities).
Specified by:
getEntityResolver in interface XMLReader

getErrorHandler

public ErrorHandler getErrorHandler()
SAX2: Returns the object used to receive callbacks for XML errors of all levels (fatal, nonfatal, warning); this is never null;
Specified by:
getErrorHandler in interface XMLReader

getFeature

public boolean getFeature(String featureId)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException
SAX2: Tells the value of the specified feature flag.
Specified by:
getFeature in interface XMLReader
Throws:
SAXNotRecognizedException - thrown if the feature flag is neither built in, nor yet assigned.

getIndex

public int getIndex(String xmlName)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getIndex in interface Attributes

getIndex

public int getIndex(String uri,
                    String local)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getIndex in interface Attributes

getLength

public int getLength()
SAX1 AttributeList, SAX2 Attributes method (don't invoke on parser);
Specified by:
getLength in interface Attributes
getLength in interface AttributeList

getLineNumber

public int getLineNumber()
SAX Locator method (don't invoke on parser);
Specified by:
getLineNumber in interface Locator

getLocalName

public String getLocalName(int index)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getLocalName in interface Attributes

getName

public String getName(int index)
SAX1 AttributeList method (don't invoke on parser);
Specified by:
getName in interface AttributeList

getProperty

public Object getProperty(String propertyId)
            throws SAXNotRecognizedException
SAX2: Returns the specified property.
Specified by:
getProperty in interface XMLReader
Throws:
SAXNotRecognizedException - thrown if the property value is neither built in, nor yet stored.

getPublicId

public String getPublicId()
SAX Locator method (don't invoke on parser);
Specified by:
getPublicId in interface Locator

getQName

public String getQName(int index)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getQName in interface Attributes

getSystemId

public String getSystemId()
SAX Locator method (don't invoke on parser);
Specified by:
getSystemId in interface Locator

getType

public String getType(int index)
SAX1 AttributeList, SAX2 Attributes method (don't invoke on parser);
Specified by:
getType in interface Attributes
getType in interface AttributeList

getType

public String getType(String xmlName)
SAX1 AttributeList, SAX2 Attributes method (don't invoke on parser);
Specified by:
getType in interface Attributes
getType in interface AttributeList

getType

public String getType(String uri,
                      String local)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getType in interface Attributes

getURI

public String getURI(int index)
SAX2 Attributes method (don't invoke on parser);
Specified by:
getURI in interface Attributes

getValue

public String getValue(int index)
SAX1 AttributeList, SAX2 Attributes method (don't invoke on parser);
Specified by:
getValue in interface Attributes
getValue in interface AttributeList

getValue

public String getValue(String xmlName)
SAX1 AttributeList, SAX2 Attributes method (don't invoke on parser);
Specified by:
getValue in interface Attributes
getValue in interface AttributeList

getValue

public String getValue(String uri,
                       String local)
SAX Attributes method (don't invoke on parser);
Specified by:
getValue in interface Attributes

isDeclared

public boolean isDeclared(int index)
Specified by:
isDeclared in interface Attributes2
Returns:
false unless the attribute was declared in the DTD.
Throws:
ArrayIndexOutOfBoundsException - When the supplied index does not identify an attribute.

isDeclared

public boolean isDeclared(String qName)
Specified by:
isDeclared in interface Attributes2
Returns:
false unless the attribute was declared in the DTD.
Throws:
IllegalArgumentException - When the supplied names do not identify an attribute.

isDeclared

public boolean isDeclared(String uri,
                          String localName)
Specified by:
isDeclared in interface Attributes2
Returns:
false unless the attribute was declared in the DTD.
Throws:
IllegalArgumentException - When the supplied names do not identify an attribute.

isSpecified

public boolean isSpecified(int index)
SAX-ext Attributes2 method (don't invoke on parser);
Specified by:
isSpecified in interface Attributes2

isSpecified

public boolean isSpecified(String xmlName)
SAX-ext Attributes2 method (don't invoke on parser);
Specified by:
isSpecified in interface Attributes2

isSpecified

public boolean isSpecified(String uri,
                           String local)
SAX-ext Attributes2 method (don't invoke on parser);
Specified by:
isSpecified in interface Attributes2

parse

public void parse(String systemId)
            throws SAXException,
                   IOException
SAX1, SAX2: Preferred API to parse an XML document, using a system identifier (URI).
Specified by:
parse in interface XMLReader
parse in interface Parser

parse

public void parse(InputSource source)
            throws SAXException,
                   IOException
SAX1, SAX2: Auxiliary API to parse an XML document, used mostly when no URI is available. If you want anything useful to happen, you should set at least one type of handler.
Specified by:
parse in interface XMLReader
parse in interface Parser
Parameters:
source - The XML input source. Don't set 'encoding' unless you know for a fact that it's correct.
Throws:
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.

setContentHandler

public void setContentHandler(ContentHandler handler)
SAX2: Assigns the object used to report the logical content of an XML document. If a document handler was set, this content handler will supplant it (but XML 1.0 style name reporting may remain enabled).
Specified by:
setContentHandler in interface XMLReader

setDTDHandler

public void setDTDHandler(DTDHandler handler)
SAX1, SAX2: Set the DTD handler for this parser.
Specified by:
setDTDHandler in interface XMLReader
setDTDHandler in interface Parser
Parameters:
handler - The object to receive DTD events.

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)

Deprecated. SAX2 programs should use the XMLReader interface and a ContentHandler.

SAX1: Set the document handler for this parser. If a content handler was set, this document handler will supplant it. The parser is set to report all XML 1.0 names rather than to filter out "xmlns" attributes (the "namespace-prefixes" feature is set to true).
Specified by:
setDocumentHandler in interface Parser
Parameters:
handler - The object to receive document events.

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
SAX1, SAX2: Set the entity resolver for this parser.
Specified by:
setEntityResolver in interface XMLReader
setEntityResolver in interface Parser
Parameters:

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
SAX1, SAX2: Set the error handler for this parser.
Specified by:
setErrorHandler in interface XMLReader
setErrorHandler in interface Parser
Parameters:
handler - The object to receive error events.

setFeature

public void setFeature(String featureId,
                       boolean value)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException
SAX2: Sets the state of feature flags in this parser. Some built-in feature flags are mutable.
Specified by:
setFeature in interface XMLReader

setLocale

public void setLocale(Locale locale)
            throws SAXException
SAX1: Sets the locale used for diagnostics; currently, only locales using the English language are supported.
Specified by:
setLocale in interface Parser
Parameters:
locale - The locale for which diagnostics will be generated

setProperty

public void setProperty(String propertyId,
                        Object value)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException
SAX2: Assigns the specified property. Like SAX1 handlers, these may be changed at any time.
Specified by:
setProperty in interface XMLReader

SAXDriver.java -- Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. Portions derived from code which carried the following notice: Copyright (c) 1997, 1998 by Microstar Software Ltd. AElfred is free for both commercial and non-commercial use and redistribution, provided that Microstar's copyright and disclaimer are retained intact. You are free to modify AElfred for your own use and to redistribute AElfred with your modifications, provided that the modifications are clearly documented. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of merchantability or fitness for a particular purpose. Please use it AT YOUR OWN RISK.