wt.federation
Class SAXElementHandler

java.lang.Object
  extended bywt.federation.SAXElementHandler
All Implemented Interfaces:
DocumentHandler, DTDHandler, EntityResolver, ErrorHandler

public class SAXElementHandler
extends Object
implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler

Event handler class for SAX.

This handler simply reports all of the events that it receives. It is useful for testing and comparing SAX implementations, and for teaching or learning about SAX. This is also a demonstration of how one class can implement all four handler interfaces.

See Also:
EntityResolver, DTDHandler, DocumentHandler, ErrorHandler

Field Summary
private  StringBuffer attributeChars
           
private  boolean attributeStarted
           
private  Vector attributeValues
           
private  boolean compatible
           
private  String elementName
           
private  String groupName
           
private  int ieVersion
           
private  Hashtable objectAttributes
           
private  Vector objects
           
private  boolean processingStatus
           
private  Hashtable statusObjectAttributes
           
private static boolean VERBOSE
           
 
Constructor Summary
SAXElementHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Character data received.
 void endDocument()
          Print a message for the end of the document.
 void endElement(String name)
          Print a message for the end of an element.
 void error(SAXParseException exception)
          Report all recoverable errors, and try to continue parsing.
 void fatalError(SAXParseException exception)
          Report all fatal errors, and try to continue parsing.
 String getElementName(AttributeList atlist)
          Traverse the passed AttributeList and find the 'NAME' attribute, and return it.
 String getElementStatus(AttributeList atlist)
          Traverse the passed AttributeList and find the 'STATUS' attribute, and return it.
 String getElementValue(AttributeList atlist)
          Traverse the passed AttributeList and find the 'VALUE' attribute, and return it.
 Vector getObjects()
           
 void ignorableWhitespace(char[] ch, int start, int length)
          Print a message for ignorable whitespace.
 void notationDecl(String name, String publicId, String systemId)
          Display notation declarations as they are reported.
 void processingInstruction(String target, String data)
          Print a message for a processing instruction.
 InputSource resolveEntity(String publicId, String systemId)
          Display requests for entity resolution.
 void setDocumentLocator(Locator locator)
          Print a message when the parser provides a locator.
 void startDocument()
          Print a message at the start of the document.
 void startElement(String name, AttributeList attributes)
          Print a message for the start of an element.
 void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
          Display unparsed entity declarations as they are reported.
 void warning(SAXParseException exception)
          Report all warnings, and continue parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributeStarted

private boolean attributeStarted

attributeChars

private StringBuffer attributeChars

attributeValues

private Vector attributeValues

compatible

private boolean compatible

elementName

private String elementName

groupName

private String groupName

ieVersion

private int ieVersion

objectAttributes

private Hashtable objectAttributes

statusObjectAttributes

private Hashtable statusObjectAttributes

objects

private Vector objects

processingStatus

private boolean processingStatus

VERBOSE

private static boolean VERBOSE
Constructor Detail

SAXElementHandler

public SAXElementHandler()
Method Detail

getObjects

public Vector getObjects()

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
Display requests for entity resolution.

The SAX parser will invoke this method to give the application a chance to resolve entities. This implementation always returns null, so that the parser will resolve the entity itself.

Specified by:
resolveEntity in interface EntityResolver
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
Display notation declarations as they are reported.

Specified by:
notationDecl in interface DTDHandler
See Also:
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
Display unparsed entity declarations as they are reported.

Specified by:
unparsedEntityDecl in interface DTDHandler
See Also:
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

setDocumentLocator

public void setDocumentLocator(Locator locator)
Print a message when the parser provides a locator.

Not all SAX parsers will provide a locator object.

Specified by:
setDocumentLocator in interface DocumentHandler
See Also:
DocumentHandler.setDocumentLocator(org.xml.sax.Locator)

startDocument

public void startDocument()
Print a message at the start of the document.

Specified by:
startDocument in interface DocumentHandler
See Also:
DocumentHandler.startDocument()

endDocument

public void endDocument()
Print a message for the end of the document.

Specified by:
endDocument in interface DocumentHandler
See Also:
DocumentHandler.endDocument()

startElement

public void startElement(String name,
                         AttributeList attributes)
Print a message for the start of an element.

Display all attributes on separate lines, indented.

Specified by:
startElement in interface DocumentHandler
See Also:
DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)

endElement

public void endElement(String name)
Print a message for the end of an element.

Specified by:
endElement in interface DocumentHandler
See Also:
DocumentHandler.endElement(java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
Character data received.

Specified by:
characters in interface DocumentHandler
See Also:
DocumentHandler.characters(char[], int, int)

getElementName

public String getElementName(AttributeList atlist)
Traverse the passed AttributeList and find the 'NAME' attribute, and return it.


getElementValue

public String getElementValue(AttributeList atlist)
Traverse the passed AttributeList and find the 'VALUE' attribute, and return it.


getElementStatus

public String getElementStatus(AttributeList atlist)
Traverse the passed AttributeList and find the 'STATUS' attribute, and return it.


ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
Print a message for ignorable whitespace.

Specified by:
ignorableWhitespace in interface DocumentHandler
See Also:
DocumentHandler.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(String target,
                                  String data)
Print a message for a processing instruction.

Specified by:
processingInstruction in interface DocumentHandler
See Also:
DocumentHandler.processingInstruction(java.lang.String, java.lang.String)

warning

public void warning(SAXParseException exception)
Report all warnings, and continue parsing.

Specified by:
warning in interface ErrorHandler
See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)

error

public void error(SAXParseException exception)
Report all recoverable errors, and try to continue parsing.

Specified by:
error in interface ErrorHandler
See Also:
ErrorHandler.error(org.xml.sax.SAXParseException)

fatalError

public void fatalError(SAXParseException exception)
Report all fatal errors, and try to continue parsing.

Note: results are no longer reliable once a fatal error has been reported.

Specified by:
fatalError in interface ErrorHandler
See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException)