edu.pdx.cs399J.xml
Class PrintPhoneNumbers

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.pdx.cs399J.xml.PrintPhoneNumbers
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class PrintPhoneNumbers
extends DefaultHandler

This program demonstrates the SAX parsing API by parsing a phonebook XML document and printing out the phone numbers in it.


Constructor Summary
PrintPhoneNumbers()
           
 
Method Summary
 void error(SAXParseException ex)
           
 void fatalError(SAXParseException ex)
           
static void main(String[] args)
          Parses an XML file using SAX with an instance of this class used for callbacks
 void startElement(String namespaceURI, String localName, String qName, Attributes attrs)
          When we see a "phone" element, print out the area code and phone number
 void warning(SAXParseException ex)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintPhoneNumbers

public PrintPhoneNumbers()
Method Detail

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
When we see a "phone" element, print out the area code and phone number

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

warning

public void warning(SAXParseException ex)
Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler

error

public void error(SAXParseException ex)
Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler

fatalError

public void fatalError(SAXParseException ex)
Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler

main

public static void main(String[] args)
Parses an XML file using SAX with an instance of this class used for callbacks



Copyright © 2000-2009 Portland State University. All Rights Reserved.