[jdom-interest] Extending JDOM classes

Jason Hunter jhunter at acm.org
Sun Aug 13 16:58:12 PDT 2000


The standard approach to this is to have your builder build
Element/Attribute subclasses with the features you want.  There have
been discussions about enhancing SAXBuilder to support this built-in.  I
suggest you participate in those discussions (archives online) and in
the meanwhile just copy SAXBuilder and have it create objects of the
type you want.  

Downsides:  Since you're adding new methods you'll have to do some
casting.  Also, when you create new elements outside the builder you'll
have to know what kind you want to create.  

-jh-

Simon Harris wrote:
> 
> As JDOM appears to provide no factory class, is there any way to have JDOM
> us my own extensions when building from XML?
> 
> Specifically I'd like to extend Element and Attribute to add some type aware
> methods such as Object getTextValue() or the like which would return
> String/BigDecimal/Boolean/etc. depending on the type defined in the schema.
> 
> Additionally I'd like the methods to cache the value so as not to have to
> re-parse the text each time it is accessed. Because of this last
> requirement, it would not be practical (nor effecient IMHO) to have some
> kind of facade over JDOM.
> 
> Regards,
> 
> Simon.
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list