[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: SAX2: Handler Interfaces
Title: RE: SAX2: Handler Interfaces > -----Original Message-----
I wasn't advocating folding the methods of all four interfaces into a single "mega-interface". Rather, I was advocating a change to the way an XMLReader implementation acquires the "auxiliary" interfaces once it gets a content handler. > My own assumption in SAX1 was that many
I don't think I made myself clear. I wasn't advocating a change to any of the XXXHandler interfaces nor to DefaultHandler. Rather, I was questioning why XMLReader needs a separate "setter" for both ContentHandler and LexicalHandler (and arguably DTDHandler and EntityResolver). The only reason to use separate "setters" is to allow someone to use a separate object per interface. However, it is hard to imagine someone calling setLexicalHandler without also calling setContentHandler. Similar (but somewhat less compelling) arguments could be made for DTDHandler and EntityResolver. Imagine an implementation of XMLReader that looked like this: class MyReader implements XMLReader {
public void setHandler(ContentHandler h) {
If you don't like the casts (which are a cornerstone of interface-based programming in Java, COM and CORBA), one could add a specific "getter" method to content handler: public abstract Object getHandler(String interfaceName); which would change the method above to look like this: public void setHandler(ContentHandler h) {
One of my main motivations for proposing this change is that I would like to see the role of XMLReader reduced. Ideally, passing around a ContentHandler reference should allow me to have sufficient information to "transmit" an entire XML Document. The way SAX2 sits now, I must pass around an XMLReader in order to give you a way to "discover" the four required interfaces. THis also means I'm passing around an object reference with methods like "setXXXHandler" and "parse", neither of which make sence. In summary, my request is that we refactor in order to have a single object reference from which I can discover all four handler/resolver interfaces. > 2. In SAX2, LexicalHandler and DeclHandler are not required
No. Java and COM are pretty much identical in this respect. Provided you avoid methodname collisions, we are fine. FWIW, COM is just a style of C++ programming, not some major MS technology. DB
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|