Class SAXDriver
- java.lang.Object
-
- com.microstar.xml.driver.SAXDriver
-
- All Implemented Interfaces:
XmlHandler,org.xml.sax.Attributes,org.xml.sax.Locator,org.xml.sax.XMLReader
public class SAXDriver extends java.lang.Object implements XmlHandler, org.xml.sax.Locator, org.xml.sax.Attributes, org.xml.sax.XMLReader
A SAX driver for Microstar's Ælfred XML parser.This driver acts as a front-end for Ælfred, and translates Ælfred's events into SAX events. It implements the SAX parser interface, and you can use it without directly calling Ælfred at all:
org.xml.sax.Parser parser = new com.microstar.xml.SAXDriver();
When you are using SAX, you do not need to use the
XmlParserorXmlHandlerclasses at all: this class is your entry point.This driver is based on the 1.0gamma version of SAX, available from http://www.megginson.com/SAX/
- Since:
- Ptolemy II 0.2
- Version:
- 1.1
- Author:
- Copyright (c) 1998 by Microstar Software Ltd., written by David Megginson <dmeggins@microstar.com>
- See Also:
XmlParser
-
-
Constructor Summary
Constructors Constructor Description SAXDriver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattribute(java.lang.String aname, java.lang.String value, boolean isSpecified)Implement com.microstar.xml.XmlHandler#attribute.voidcharData(char[] ch, int start, int length)Implement com.microstar.xml.XmlHandler#charData.voiddoctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Implement com.microstar.xml.XmlHandler#doctypeDecl.voidendDocument()Implement com.microstar.xml.XmlHandler#endDocument.voidendElement(java.lang.String elname)Implement com.microstar.xml.XmlHandler#endElement.voidendExternalEntity(java.lang.String systemId)Implement com.microstar.xml.XmlHandler#endExternalEntity.voiderror(java.lang.String message, java.lang.String url, int line, int column)Implement com.microstar.xml.XmlHandler#error.intgetColumnNumber()org.xml.sax.ContentHandlergetContentHandler()org.xml.sax.DTDHandlergetDTDHandler()org.xml.sax.EntityResolvergetEntityResolver()org.xml.sax.ErrorHandlergetErrorHandler()booleangetFeature(java.lang.String name)intgetIndex(java.lang.String qName)intgetIndex(java.lang.String uri, java.lang.String localPart)intgetLength()intgetLineNumber()java.lang.StringgetLocalName(int index)java.lang.StringgetName(int i)java.lang.ObjectgetProperty(java.lang.String name)java.lang.StringgetPublicId()java.lang.StringgetQName(int index)java.lang.StringgetSystemId()java.lang.StringgetType(int i)java.lang.StringgetType(java.lang.String name)java.lang.StringgetType(java.lang.String uri, java.lang.String localName)java.lang.StringgetURI(int index)java.lang.StringgetValue(int i)java.lang.StringgetValue(java.lang.String name)java.lang.StringgetValue(java.lang.String uri, java.lang.String localName)voidignorableWhitespace(char[] ch, int start, int length)Implement com.microstar.xml.XmlHandler#ignorableWhitespace.voidparse(java.lang.String systemId)Parse an XML document from a system identifier (URI).voidparse(org.xml.sax.InputSource source)Parse a document.voidprocessingInstruction(java.lang.String target, java.lang.String data)Implement com.microstar.xml.XmlHandler#processingInstruction.java.lang.ObjectresolveEntity(java.lang.String publicId, java.lang.String systemId)Implement com.microstar.xml.XmlHandler.resolveSystemIdvoidsetContentHandler(org.xml.sax.ContentHandler handler)voidsetDocumentHandler(org.xml.sax.ContentHandler handler)Set the document handler for this parser.voidsetDTDHandler(org.xml.sax.DTDHandler handler)Set the DTD handler for this parser.voidsetEntityResolver(org.xml.sax.EntityResolver resolver)Set the entity resolver for this parser.voidsetErrorHandler(org.xml.sax.ErrorHandler handler)Set the error handler for this parser.voidsetFeature(java.lang.String name, boolean value)voidsetLocale(java.util.Locale locale)Set the locale.voidsetProperty(java.lang.String name, java.lang.Object value)voidstartDocument()Implement com.microstar.xml.XmlHandler#startDocument.voidstartElement(java.lang.String elname)Implement com.microstar.xml.XmlHandler#startElement.voidstartExternalEntity(java.lang.String systemId)Implement com.microstar.xml.XmlHandler#startExternalEntity.
-
-
-
Method Detail
-
setLocale
public void setLocale(java.util.Locale locale) throws org.xml.sax.SAXExceptionSet the locale.- Parameters:
locale- The Locale- Throws:
org.xml.sax.SAXException- Always thrown in this base class.
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Set the entity resolver for this parser.- Specified by:
setEntityResolverin interfaceorg.xml.sax.XMLReader- Parameters:
resolver- The object to receive resolve entity events.
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
Set the DTD handler for this parser.- Specified by:
setDTDHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
handler- The object to receive DTD events.
-
setDocumentHandler
public void setDocumentHandler(org.xml.sax.ContentHandler handler)
Set the document handler for this parser.- Parameters:
handler- The object to receive document events.
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Set the error handler for this parser.- Specified by:
setErrorHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
handler- The object to receive error events.
-
parse
public void parse(org.xml.sax.InputSource source) throws org.xml.sax.SAXExceptionParse a document.If you want anything useful to happen, you should set at least one type of handler.
- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Parameters:
source- The XML input source.- Throws:
org.xml.sax.SAXException- The handlers may throw any exception.- See Also:
setEntityResolver(org.xml.sax.EntityResolver),setDTDHandler(org.xml.sax.DTDHandler),setDocumentHandler(org.xml.sax.ContentHandler),setErrorHandler(org.xml.sax.ErrorHandler)
-
parse
public void parse(java.lang.String systemId) throws org.xml.sax.SAXExceptionParse an XML document from a system identifier (URI).- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#startDocument.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
startDocumentin interfaceXmlHandler- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.startDocument()
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#endDocument.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
endDocumentin interfaceXmlHandler- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.endDocument()
-
resolveEntity
public java.lang.Object resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOExceptionImplement com.microstar.xml.XmlHandler.resolveSystemIdTranslate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
resolveEntityin interfaceXmlHandler- Parameters:
publicId- The public identifier, or null if none was supplied.systemId- The system identifier.- Returns:
- The replacement system identifier, or null to use the default.
- Throws:
org.xml.sax.SAXException- May throw any exception.java.io.IOException- See Also:
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
-
startExternalEntity
public void startExternalEntity(java.lang.String systemId) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#startExternalEntity.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
startExternalEntityin interfaceXmlHandler- Parameters:
systemId- The URI of the external entity that is starting.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.startExternalEntity(java.lang.String)
-
endExternalEntity
public void endExternalEntity(java.lang.String systemId) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#endExternalEntity.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
endExternalEntityin interfaceXmlHandler- Parameters:
systemId- The URI of the external entity that is ending.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.endExternalEntity(java.lang.String)
-
doctypeDecl
public void doctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#doctypeDecl.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
doctypeDeclin interfaceXmlHandler- Parameters:
name- The document type name.publicId- The public identifier, or null if unspecified.systemId- The system identifier, or null if unspecified.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
-
attribute
public void attribute(java.lang.String aname, java.lang.String value, boolean isSpecified) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#attribute.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
attributein interfaceXmlHandler- Parameters:
aname- The name of the attribute.value- The value of the attribute, or null if the attribute is#IMPLIED.isSpecified- True if the value was specified, false if it was defaulted from the DTD.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
-
startElement
public void startElement(java.lang.String elname) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#startElement.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
startElementin interfaceXmlHandler- Parameters:
elname- The element type name.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.startElement(java.lang.String)
-
endElement
public void endElement(java.lang.String elname) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#endElement.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
endElementin interfaceXmlHandler- Parameters:
elname- The element type name.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.endElement(java.lang.String)
-
charData
public void charData(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#charData.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
charDatain interfaceXmlHandler- Parameters:
ch- The character data.start- The starting position in the array.length- The number of characters available.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.charData(char[], int, int)
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#ignorableWhitespace.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
ignorableWhitespacein interfaceXmlHandler- Parameters:
ch- The literal whitespace characters.start- The starting position in the array.length- The number of whitespace characters available.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.ignorableWhitespace(char[], int, int)
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#processingInstruction.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
processingInstructionin interfaceXmlHandler- Parameters:
target- The target (the name at the start of the PI).data- The data, if any (the rest of the PI).- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.processingInstruction(java.lang.String, java.lang.String)
-
error
public void error(java.lang.String message, java.lang.String url, int line, int column) throws org.xml.sax.SAXExceptionImplement com.microstar.xml.XmlHandler#error.Translate to the SAX interface.
Users should never invoke this method directly.
- Specified by:
errorin interfaceXmlHandler- Parameters:
message- The error message.url- The system identifier of the entity that contains the error.line- The approximate line number of the error.column- The approximate column number of the error.- Throws:
org.xml.sax.SAXException- May throw any exception.- See Also:
XmlHandler.error(java.lang.String, java.lang.String, int, int)
-
getLength
public int getLength()
- Specified by:
getLengthin interfaceorg.xml.sax.Attributes
-
getName
public java.lang.String getName(int i)
-
getType
public java.lang.String getType(int i)
- Specified by:
getTypein interfaceorg.xml.sax.Attributes
-
getValue
public java.lang.String getValue(int i)
- Specified by:
getValuein interfaceorg.xml.sax.Attributes
-
getType
public java.lang.String getType(java.lang.String name)
- Specified by:
getTypein interfaceorg.xml.sax.Attributes
-
getValue
public java.lang.String getValue(java.lang.String name)
- Specified by:
getValuein interfaceorg.xml.sax.Attributes
-
getPublicId
public java.lang.String getPublicId()
- Specified by:
getPublicIdin interfaceorg.xml.sax.Locator
-
getSystemId
public java.lang.String getSystemId()
- Specified by:
getSystemIdin interfaceorg.xml.sax.Locator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumberin interfaceorg.xml.sax.Locator
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumberin interfaceorg.xml.sax.Locator
-
getFeature
public boolean getFeature(java.lang.String name)
- Specified by:
getFeaturein interfaceorg.xml.sax.XMLReader
-
setFeature
public void setFeature(java.lang.String name, boolean value)- Specified by:
setFeaturein interfaceorg.xml.sax.XMLReader
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getPropertyin interfaceorg.xml.sax.XMLReader
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)- Specified by:
setPropertyin interfaceorg.xml.sax.XMLReader
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
- Specified by:
getEntityResolverin interfaceorg.xml.sax.XMLReader
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
- Specified by:
getDTDHandlerin interfaceorg.xml.sax.XMLReader
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler handler)
- Specified by:
setContentHandlerin interfaceorg.xml.sax.XMLReader
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
- Specified by:
getContentHandlerin interfaceorg.xml.sax.XMLReader
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
- Specified by:
getErrorHandlerin interfaceorg.xml.sax.XMLReader
-
getURI
public java.lang.String getURI(int index)
- Specified by:
getURIin interfaceorg.xml.sax.Attributes
-
getLocalName
public java.lang.String getLocalName(int index)
- Specified by:
getLocalNamein interfaceorg.xml.sax.Attributes
-
getQName
public java.lang.String getQName(int index)
- Specified by:
getQNamein interfaceorg.xml.sax.Attributes
-
getIndex
public int getIndex(java.lang.String uri, java.lang.String localPart)- Specified by:
getIndexin interfaceorg.xml.sax.Attributes
-
getIndex
public int getIndex(java.lang.String qName)
- Specified by:
getIndexin interfaceorg.xml.sax.Attributes
-
getType
public java.lang.String getType(java.lang.String uri, java.lang.String localName)- Specified by:
getTypein interfaceorg.xml.sax.Attributes
-
getValue
public java.lang.String getValue(java.lang.String uri, java.lang.String localName)- Specified by:
getValuein interfaceorg.xml.sax.Attributes
-
-