|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.microstar.xml.SAXDriver
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
XmlParser
or XmlHandler
classes 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/
Parser
,
XmlParser
Constructor Summary | |
SAXDriver()
|
Method Summary | |
void |
attribute(java.lang.String aname,
java.lang.String value,
boolean isSpecified)
Implement com.microstar.xml.XmlHandler#attribute. |
void |
charData(char[] ch,
int start,
int length)
Implement com.microstar.xml.XmlHandler#charData. |
void |
doctypeDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Implement com.microstar.xml.XmlHandler#doctypeDecl. |
void |
endDocument()
Implement com.microstar.xml.XmlHandler#endDocument. |
void |
endElement(java.lang.String elname)
Implement com.microstar.xml.XmlHandler#endElement. |
void |
endExternalEntity(java.lang.String systemId)
Implement com.microstar.xml.XmlHandler#endExternalEntity. |
void |
error(java.lang.String message,
java.lang.String url,
int line,
int column)
Implement com.microstar.xml.XmlHandler#error. |
int |
getColumnNumber()
Return the column number where the current document event ends. |
int |
getLength()
Return the number of attributes in this list. |
int |
getLineNumber()
Return the line number where the current document event ends. |
java.lang.String |
getName(int i)
Return the name of an attribute in this list (by position). |
java.lang.String |
getPublicId()
Return the public identifier for the current document event. |
java.lang.String |
getSystemId()
Return the system identifier for the current document event. |
java.lang.String |
getType(int i)
Return the type of an attribute in the list (by position). |
java.lang.String |
getType(java.lang.String name)
Return the type of an attribute in the list (by name). |
java.lang.String |
getValue(int i)
Return the value of an attribute in the list (by position). |
java.lang.String |
getValue(java.lang.String name)
Return the value of an attribute in the list (by name). |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Implement com.microstar.xml.XmlHandler#ignorableWhitespace. |
void |
parse(InputSource source)
Parse a document. |
void |
parse(java.lang.String systemId)
Parse an XML document from a system identifier (URI). |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Implement com.microstar.xml.XmlHandler#processingInstruction. |
java.lang.Object |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Implement com.microstar.xml.XmlHandler.resolveSystemId |
void |
setDocumentHandler(DocumentHandler handler)
Set the document handler for this parser. |
void |
setDTDHandler(DTDHandler handler)
Set the DTD handler for this parser. |
void |
setEntityResolver(EntityResolver resolver)
Set the entity resolver for this parser. |
void |
setErrorHandler(ErrorHandler handler)
Set the error handler for this parser. |
void |
setLocale(java.util.Locale locale)
Set the locale. |
void |
startDocument()
Implement com.microstar.xml.XmlHandler#startDocument. |
void |
startElement(java.lang.String elname)
Implement com.microstar.xml.XmlHandler#startElement. |
void |
startExternalEntity(java.lang.String systemId)
Implement com.microstar.xml.XmlHandler#startExternalEntity. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SAXDriver()
Method Detail |
public void setLocale(java.util.Locale locale) throws SAXException
setLocale
in interface Parser
locale
- A Java Locale object.
SAXException
- Throws an exception
(using the previous or default locale) if the
requested locale is not supported.Parser.setLocale(java.util.Locale)
public void setEntityResolver(EntityResolver resolver)
setEntityResolver
in interface Parser
resolver
- The object for resolving entities.Parser.setEntityResolver(org.xml.sax.EntityResolver)
public void setDTDHandler(DTDHandler handler)
setDTDHandler
in interface Parser
handler
- The object to receive DTD events.Parser.setDTDHandler(org.xml.sax.DTDHandler)
public void setDocumentHandler(DocumentHandler handler)
setDocumentHandler
in interface Parser
handler
- The object to receive document events.Parser.setDocumentHandler(org.xml.sax.DocumentHandler)
public void setErrorHandler(ErrorHandler handler)
setErrorHandler
in interface Parser
handler
- The object to receive error events.Parser.setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(InputSource source) throws SAXException
If you want anything useful to happen, you should set at least one type of handler.
parse
in interface Parser
source
- The XML input source.
SAXException
- The handlers may throw any exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.Parser.parse(InputSource)
,
setEntityResolver(org.xml.sax.EntityResolver)
,
setDTDHandler(org.xml.sax.DTDHandler)
,
setDocumentHandler(org.xml.sax.DocumentHandler)
,
setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(java.lang.String systemId) throws SAXException
parse
in interface Parser
systemId
- The system identifier (URI).
SAXException
- Any SAX exception, possibly
wrapping another exception.Parser.parse(String)
public void startDocument() throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
startDocument
in interface XmlHandler
SAXException
- May throw any exception.XmlHandler.startDocument()
public void endDocument() throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
endDocument
in interface XmlHandler
SAXException
- May throw any exception.XmlHandler.endDocument()
public java.lang.Object resolveEntity(java.lang.String publicId, java.lang.String systemId) throws SAXException, java.io.IOException
Translate to the SAX interface.
Users should never invoke this method directly.
resolveEntity
in interface XmlHandler
publicId
- The public identifier, or null if none was supplied.systemId
- The system identifier.
SAXException
- May throw any exception.
java.io.IOException
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void startExternalEntity(java.lang.String systemId) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
startExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is starting.
SAXException
- May throw any exception.XmlHandler.startExternalEntity(java.lang.String)
public void endExternalEntity(java.lang.String systemId) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
endExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is ending.
SAXException
- May throw any exception.XmlHandler.endExternalEntity(java.lang.String)
public void doctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
doctypeDecl
in interface XmlHandler
name
- The document type name.publicId
- The public identifier, or null if unspecified.systemId
- The system identifier, or null if unspecified.
SAXException
- May throw any exception.XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
public void attribute(java.lang.String aname, java.lang.String value, boolean isSpecified) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
attribute
in interface XmlHandler
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.
SAXException
- May throw any exception.XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
public void startElement(java.lang.String elname) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
startElement
in interface XmlHandler
elname
- The element type name.
SAXException
- May throw any exception.XmlHandler.startElement(java.lang.String)
public void endElement(java.lang.String elname) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
endElement
in interface XmlHandler
elname
- The element type name.
SAXException
- May throw any exception.XmlHandler.endElement(java.lang.String)
public void charData(char[] ch, int start, int length) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
charData
in interface XmlHandler
ch
- The character data.start
- The starting position in the array.length
- The number of characters available.
SAXException
- May throw any exception.XmlHandler.charData(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
ignorableWhitespace
in interface XmlHandler
ch
- The literal whitespace characters.start
- The starting position in the array.length
- The number of whitespace characters available.
SAXException
- May throw any exception.XmlHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
processingInstruction
in interface XmlHandler
target
- The target (the name at the start of the PI).data
- The data, if any (the rest of the PI).
SAXException
- May throw any exception.XmlHandler.processingInstruction(java.lang.String, java.lang.String)
public void error(java.lang.String message, java.lang.String url, int line, int column) throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
error
in interface XmlHandler
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.
SAXException
- May throw any exception.XmlHandler.error(java.lang.String, java.lang.String, int, int)
public int getLength()
AttributeList
The SAX parser may provide attributes in any arbitrary order, regardless of the order in which they were declared or specified. The number of attributes may be zero.
getLength
in interface AttributeList
public java.lang.String getName(int i)
AttributeList
The names must be unique: the SAX parser shall not include the same attribute twice. Attributes without values (those declared #IMPLIED without a value specified in the start tag) will be omitted from the list.
If the attribute name has a namespace prefix, the prefix will still be attached.
getName
in interface AttributeList
i
- The index of the attribute in the list (starting at 0).
AttributeList.getLength()
public java.lang.String getType(int i)
AttributeList
The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).
If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommentation (clause 3.3.3, "Attribute-Value Normalization").
For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN".
getType
in interface AttributeList
i
- The index of the attribute in the list (starting at 0).
AttributeList.getLength()
,
AttributeList.getType(java.lang.String)
public java.lang.String getValue(int i)
AttributeList
If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single string separated by whitespace.
getValue
in interface AttributeList
i
- The index of the attribute in the list (starting at 0).
AttributeList.getLength()
,
AttributeList.getValue(java.lang.String)
public java.lang.String getType(java.lang.String name)
AttributeList
The return value is the same as the return value for getType(int).
If the attribute name has a namespace prefix in the document, the application must include the prefix here.
getType
in interface AttributeList
name
- The name of the attribute.
AttributeList.getType(int)
public java.lang.String getValue(java.lang.String name)
AttributeList
The return value is the same as the return value for getValue(int).
If the attribute name has a namespace prefix in the document, the application must include the prefix here.
getValue
in interface AttributeList
AttributeList.getValue(int)
public java.lang.String getPublicId()
Locator
This will be the public identifier
getPublicId
in interface Locator
Locator.getSystemId()
public java.lang.String getSystemId()
Locator
If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
getSystemId
in interface Locator
Locator.getPublicId()
public int getLineNumber()
Locator
getLineNumber
in interface Locator
Locator.getColumnNumber()
public int getColumnNumber()
Locator
getColumnNumber
in interface Locator
Locator.getLineNumber()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |