|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | 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
Field Summary | |
private java.util.Vector |
attributeNames
|
private java.util.Vector |
attributeValues
|
private HandlerBase |
base
|
private DocumentHandler |
documentHandler
|
private DTDHandler |
dtdHandler
|
private java.lang.String |
elementName
|
private EntityResolver |
entityResolver
|
private java.util.Stack |
entityStack
|
private ErrorHandler |
errorHandler
|
private XmlParser |
parser
|
private boolean |
seenDTDEvents
|
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. |
private void |
closeStreams(InputSource source)
Close any streams provided. |
private void |
deliverDTDEvents()
Before the first startElement event, deliver all notation and unparsed entity declarations. |
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 |
|
Field Detail |
private HandlerBase base
private XmlParser parser
private boolean seenDTDEvents
private EntityResolver entityResolver
private DTDHandler dtdHandler
private DocumentHandler documentHandler
private ErrorHandler errorHandler
private java.lang.String elementName
private java.util.Stack entityStack
private java.util.Vector attributeNames
private java.util.Vector attributeValues
Constructor Detail |
public SAXDriver()
Method Detail |
public void setLocale(java.util.Locale locale) throws SAXException
Parser.setLocale(java.util.Locale)
public void setEntityResolver(EntityResolver resolver)
handler
- The object to receive entity events.Parser.setEntityResolver(org.xml.sax.EntityResolver)
public void setDTDHandler(DTDHandler handler)
handler
- The object to receive DTD events.Parser.setDTDHandler(org.xml.sax.DTDHandler)
public void setDocumentHandler(DocumentHandler handler)
handler
- The object to receive document events.Parser.setDocumentHandler(org.xml.sax.DocumentHandler)
public void setErrorHandler(ErrorHandler handler)
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.
source
- The XML input source.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
Parser.parse(String)
private void closeStreams(InputSource source) throws java.io.IOException
public void startDocument() throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
XmlHandler.startDocument()
public void endDocument() throws SAXException
Translate to the SAX interface.
Users should never invoke this method directly.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
XmlHandler.error(java.lang.String, java.lang.String, int, int)
private void deliverDTDEvents() throws SAXException
public int getLength()
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.
public java.lang.String getName(int i)
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.
i
- The index of the attribute in the list (starting at 0).AttributeList.getLength()
public java.lang.String getType(int i)
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".
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)
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.
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)
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.
name
- The name of the attribute.AttributeList.getType(int)
public java.lang.String getValue(java.lang.String name)
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.
i
- The index of the attribute in the list.AttributeList.getValue(int)
public java.lang.String getPublicId()
This will be the public identifier
Locator.getSystemId()
public java.lang.String getSystemId()
If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
Locator.getPublicId()
public int getLineNumber()
Locator.getColumnNumber()
public int getColumnNumber()
Locator.getLineNumber()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |