While
it is great that there are so many SAX parsers available, the thing that bothers
me is that my application has to know what Parser to load in just to use
SAX. And this means that even is a SAX parser is available on the
users machine, they may still have to download the one I use to to run my
application.
If
there is already a solution for this, then please let me
know.
David
Megginson had mentioned the sax.parser property as a possible solution, but I
would like to see the following my general solution:
public class org.sax.ParserFactory() { /* static methods */ // Registers a SAX driver public static void addParserFactory(); // Retrieves all registered SAX drivers public static ParserFactory[] getParserFactorys(); // Conveince method to return a parser // from the first registered driver public static Parser createDefaultParser(); /* Instance Methods */ // Returns a new Parser public Parser createParser(); // Various identifying methods // Subject to change for what appropriate method abstract public String getDriverName(); abstract public long getDriverVersion(); abstract public long getSAXVersion(); }
If the
above was implemented, then the following piece of code in the ParserFactory
implementation could automatically register the SAX Driver. static { org.sax.ParserFactory.addParserFactory( new MyParserFactory() ); }
I think this is a relative clean and forward
compatible way to handle SAX Drivers. And simplifies life for SAX based
application programmers. I realize it is a bit heavy weight since it
require that the Factory be an abstract class instead of an interface, but I
think the benefit is worth it.
Any thoughts?
Andrew n marshall
student - artist - programmer http://www.media-electronica.com/anm-bin/anm "Everyone
a mentor, Everyone a pupil"
|