[jdom-interest] PROPOSAL: Remove most constructors from XMLOu tputter (was round trip XML)

James Strachan james at metastuff.com
Wed Oct 18 09:39:57 PDT 2000


Agreed. Though the problem with this is that an XMLOutputter instance is
mutable and so could me changed and things then get wierd. e.g.

    XMLOutputter.COMPACT.setNewLines( true );

So maybe the better solution is to not go with the 'XMLOutConfiguration'
object, nor with the static varibles but just provide static factory methods
to construct different standard configurations.

e.g.


public static XMLOutputter createCompact() {
    XMLOutputter answer = new XMLOutputter();
    answer.setNewLines( false );
    ...
    return answer;
}

public static XMLOutputter createVerbose() {
    ...
}


Regards
James

James Strachan
=============
email: james at metastuff.com
web: http://www.metastuff.com
----- Original Message -----
From: "Alex Chaffee" <guru at edamame.stinky.com>
To: "James Strachan" <james at metastuff.com>
Cc: "bob" <bob at accurev.com>; <alex at jguru.com>; "Brad Morgan"
<Brad.Morgan at e-pubcorp.com>; <jdom-interest at jdom.org>
Sent: Wednesday, October 18, 2000 5:14 PM
Subject: Re: [jdom-interest] PROPOSAL: Remove most constructors from XMLOu
tputter (was round trip XML)


> > Also then the common configurations of the XMLOutputter could be
declared as
> > final variables so thing like the following could be done:-
> >
> >     XMLOutputter out = new XMLOutputter( XMLOutConfiguration.MINIMAL );
> >
> > where the values could be
> >
> >     MINIMAL, NORMAL, VERBOSE etc.
> >
> > so common sets of configuration options such as (new lines + whitespace)
can
> > be used as a single constructor argument.
>
> That's also a neat idea, but can easily be done as static variables on
> XMLOutputter, e.g.
>
> public class XMLOutputter {
>
> public static final XMLOutputter COMPACT = new XMLOutputter();
> static {
> COMPACT.setTrimText(true);
> }
>
> ...
> }
>
> --
> Alex Chaffee                       mailto:alex at jguru.com
> jGuru - Java News and FAQs         http://www.jguru.com/alex/
> Creator of Gamelan                 http://www.gamelan.com/
> Founder of Purple Technology       http://www.purpletech.com/
> Curator of Stinky Art Collective   http://www.stinky.com/
>


If you are not the addressee of this confidential e-mail and any
attachments, please delete it and inform the sender; unauthorised
redistribution or publication is prohibited. Views expressed are those of
the author and do not necessarily represent those of Citria Limited.



More information about the jdom-interest mailing list