[jdom-interest] factory helper

rpcee rpcee at operamail.com
Wed Oct 24 09:42:40 PDT 2001

Attached is a little class that makes jdom factories, to save having to write 
them. You just specify the subclasses you want to use, eg:

     FactoryMaker fm = new FactoryMaker(MyElement.class);

     SAXBuilder builder = new SAXBuilder();


     String test = "<?xml version='1.0'?><root><child1 

     Document doc = builder.build(new StringReader(test));

     XMLOutputter op = new XMLOutputter("   ", true);
     op.output(doc, System.out);

I have only done minimal testing on (only) Element and Attribute subclasses, I 
find it handy when messing about with JDOM; maybe production use would use a 
proper factory for efficiency.

Currently if the specified subclass doesn't have a particular constructor, the 
factory method invokes the JDOM base class constructor and prints a message; 
change the invoke() method to change this behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FactoryMaker.zip
Type: application/x-zip-compressed
Size: 1204 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20011024/7141515a/FactoryMaker.bin

More information about the jdom-interest mailing list