|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
samples.sax.SAXParsingSample
public class SAXParsingSample
Parses a FI document using SAXDocumentParser.
The sample parses data/inv1a.finf as specified in the build.xml and handles SAX events to display corresponding content in XML format. The sample class entends DefaultHandler interface making itself a ContentHandler. Since the FastInfoset SAX package does not implement factory, a document parser is instantiated directly. The sample class implements some major event-handling methods as defined in the ContentHandler, such as startDocument, endDocument, startElement, endElement, and characters. In this sample, these methods simply write out the content to System.out.
| Constructor Summary | |
|---|---|
SAXParsingSample()
Creates a new instance of FIParser |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Handles characters event. |
void |
endDocument()
Handles endDocument event |
void |
endElement(String namespaceURI,
String localName,
String qName)
Handles endElement event. |
static void |
main(String[] argv)
Starts the sample. |
void |
startDocument()
Handles startDocument event and prints out file header. |
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes attributes)
Handles startElement event. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SAXParsingSample()
| Method Detail |
|---|
public static void main(String[] argv)
argv - FI document filename
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerSAXException
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerSAXException
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes attributes)
throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - namespace URIlocalName - The local name (without prefix), or the empty string if Namespace processing is not being performed.qName - The qualified name (with prefix), or the empty string if qualified names are not available.attributes - The specified or defaulted attributes.
SAXException
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - namespace URIlocalName - The local name (without prefix), or the empty string if Namespace processing is not being performed.qName - The qualified name (with prefix), or the empty string if qualified names are not available.
SAXException
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - The charactersstart - The start position in the character array.length - The number of characters to use from the character array.
SAXException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||