com.infoengine.object.factory
Class XML2Group

java.lang.Object
  extended bycom.infoengine.object.factory.XML2Group
All Implemented Interfaces:
DocumentHandler, DTDHandler, ErrorHandler, I_readGroupXML

public class XML2Group
extends Object
implements I_readGroupXML

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
static String ATT_TAG
           
private  Hashtable attValues
           
static String DATA_TAG
           
static String DATUM_TAG
           
(package private)  boolean DEBUG
           
static String ELEMENT_TAG
           
(package private)  int foundErrorLevel
           
static String GROUP_TAG
           
(package private)  boolean inMessage
           
static String KEY_TAG
           
(package private)  Att lastAtt
           
(package private)  Element lastElem
           
static String MESSAGE_TAG
           
static String MIMETYPE_TAG
           
static String NAME_TAG
           
static String NC_TAG
           
(package private)  Group outGroup
           
(package private)  StringBuffer returnData
           
static String TYPE_TAG
           
static String VALUE_TAG
           
 
Fields inherited from interface com.infoengine.object.factory.I_readGroupXML
PARSE_CRITICAL_ERROR, PARSE_OK, PARSE_RECOVERABLE_ERROR, PARSE_WARNING
 
Constructor Summary
XML2Group()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Print a message for character data.
private static void display(char[] ch, int start, int length)
          Display text, escaping some characters.
 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 getElement(String attribute, AttributeList atlist)
          Fish through the passed AttributeList and find the attribute, and return it.
 int getErrorLevel()
           
 Group getGroup()
           
 Group getOutput()
           
 void ignorableWhitespace(char[] ch, int start, int length)
          Print a message for ignorable whitespace.
static void main(String[] args)
           
 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.
 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)
           
 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

DEBUG

boolean DEBUG

inMessage

boolean inMessage

outGroup

Group outGroup

lastElem

Element lastElem

lastAtt

Att lastAtt

returnData

StringBuffer returnData

foundErrorLevel

int foundErrorLevel

GROUP_TAG

public static final String GROUP_TAG
See Also:
Constant Field Values

MESSAGE_TAG

public static final String MESSAGE_TAG
See Also:
Constant Field Values

ELEMENT_TAG

public static final String ELEMENT_TAG
See Also:
Constant Field Values

NC_TAG

public static final String NC_TAG
See Also:
Constant Field Values

ATT_TAG

public static final String ATT_TAG
See Also:
Constant Field Values

DATUM_TAG

public static final String DATUM_TAG
See Also:
Constant Field Values

NAME_TAG

public static final String NAME_TAG
See Also:
Constant Field Values

TYPE_TAG

public static final String TYPE_TAG
See Also:
Constant Field Values

KEY_TAG

public static final String KEY_TAG
See Also:
Constant Field Values

VALUE_TAG

public static final String VALUE_TAG
See Also:
Constant Field Values

DATA_TAG

public static final String DATA_TAG
See Also:
Constant Field Values

MIMETYPE_TAG

public static final String MIMETYPE_TAG
See Also:
Constant Field Values

attValues

private Hashtable attValues
Constructor Detail

XML2Group

public XML2Group()
Method Detail

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)

getOutput

public Group getOutput()
Specified by:
getOutput in interface I_readGroupXML

getErrorLevel

public int getErrorLevel()
Specified by:
getErrorLevel in interface I_readGroupXML

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()

getGroup

public Group getGroup()

startElement

public void startElement(String name,
                         AttributeList attributes)
Specified by:
startElement in interface DocumentHandler

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)
Print a message for character data.

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

getElement

public String getElement(String attribute,
                         AttributeList atlist)
Fish through the passed AttributeList and find the 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)

display

private static void display(char[] ch,
                            int start,
                            int length)
Display text, escaping some characters.


main

public static void main(String[] args)