HandlerStack provides support for dispatching SAX
events to the appropriate target during processing of an XML
document.
Writing an event handler for a SAX parser and being object oriented
isn't easy. Most people tend to write one large event handler that
knows far too much about the objects that it has to create and
provide with information. According to the object oriented approach,
every object should implement its own handling for the parts of the
XML text that provides information about the object's state.
This means changing the parser's content handler in a controlled
way. Each time that a handler encounters an element that denotes
the start of another object, it should create another object and
delegate further processing to this object. Or even better, it should
call a (static) factory method for the class associated with the
encountered element and leave all further processing to the factory
method.
Effectively, this results in a stack of handler with events being
delivered to the top of stack handler. This class implements such
a stack with as much automation as possible.
|