[jdom-interest] Re: Fast or Safe?

Simon Harris Haruki_Zaemon at hotmail.com
Fri Sep 1 14:56:55 PDT 2000

Why not have our cake and eat it too. If all you want is simple element and
attribute stuff, use new Element("foo"), new Attribute("bar") etc. And if
you want more flexibility use a factory. IMHO both these aims can be
achieved with very little effort by simply adding a factory that the build
and outputter use. if no factory is specified on construction, use the
DefaultFactory which just creates the existing Element and Attributes, etc
as I could do myself.

I have in a previous post suggest added interfaces into the equation but
there is no necessity to do so. If we force everyone to extend the existing
Element class (as an example) then we need no interfaces. I could build my
own factory that extends DefaultFactory and return my own class that extends

This solution DOESN'NT break ANY existing code AND allows me to add my own
sub-classes of Element, Attribute, whatever and have JDOM work with these as
natively as the existing classes.


----- Original Message -----
From: "Kevin Hunt" <Kevin.Hunt at ariba.com>
To: <jdom-interest at jdom.org>
Sent: Saturday, September 02, 2000 8:06 AM
Subject: RE: [jdom-interest] Re: Fast or Safe?

> Just a lurker on the list, but...
> My vote is for no factory for element creation, and little or no up-tree
> checking.  What drew me to JDOM in the first place were its simplicity (I
> can teach a Java newbie how it works in no time; a factory is a
> concept and removes the "new" syntax that people are used to when creating
> new objects), and its speed (heck, even the O'Reilly book says it's nearly
> as fast as SAX).  I think we're making this overcomplicated for the
> relatively small number of problems that would arise.
> Why not just throw an exception when XMLOutputter hits an element it
> touched?  That would at least alert the programmer that they're
> creating/adding elements in a bad way.  Or perhaps add a method to
> that would remove any infinite element recursion?
> -kevin hunt
> ---
> This message does not represent the views of Ariba...
> > -----Original Message-----
> > From: jdom-interest-admin at jdom.org
> > [mailto:jdom-interest-admin at jdom.org]On Behalf Of David W. Smiley
> > Sent: Friday, September 01, 2000 12:34 PM
> > To: mago at mail.internet.com.mx
> > Cc: jdom-interest at jdom.org
> > Subject: Re: [jdom-interest] Re: Fast or Safe?
> >
> >
> > > I wonder what percentage of the programs using JDOM are
> > only using it to
> > > parse
> > > and extract information from an XML file by using a SAXBuilder or
> > > DOMBuilder, and
> > > therefore do not have any line of code where they
> > explicitly create an
> > > Element
> > > (or Attribute, etc.). If SAXBuilder and DOMBuilder use a
> > default factory
> > > unless told
> > > otherwise, then none of those programs would be affected.
> > > --
> > >
> > > Gerardo Horvilleur
> > > mago at mail.internet.com.mx
> >
> > It's probably a small amount and will remain to be.
> > Regardless; JDOM is
> > in beta and I think any change deemed for the better should
> > be made now
> > while we can before we lock ourselves in.
> >
> > -- David Smiley
> >
> > _______________________________________________
> > To control your jdom-interest membership:
> > http://lists.denveronline.net/mailman/options/jdom-interest/yo
> uraddr at yourhost.com
> _______________________________________________
> To control your jdom-interest membership:

More information about the jdom-interest mailing list