[jdom-interest] Deprecating some XMLOutputter constructors

guru at stinky.com guru at stinky.com
Tue Jun 19 08:57:16 PDT 2001


I used to think maybe XMLOutputter should have only a default
constructor, and that all configuration should happen with setters.
Now I realize the importance of new XMLOutputter("\t",
true).outputString(element) and the like. 

I'd still like to deprecate/remove some constructors that seem
redundant:

* public XMLOutputter(String indent) 

since if you're setting indent, there's a 99.99% chance you're also
setting newlines, so you can just use XMLOuputter(String indent,
boolean newlines) -- I doubt if anyone has ever actually used this
one.

* public XMLOutputter(String indent, boolean newlines, String encoding)

since I personally consider encoding to be an "optional" feature, so
why should encoding get its own constructor, when other optional
features like setting the line separator don't?  Does anyone use
encoding regularly enough to justify this being a constructor rather
than a setter?

I'd also like to *add* a constructor:

* public XMLOutputter(String indent, boolean newlines, boolean normalizeText)

because that would be all you need for "pretty-printing", which is
probably what people what 80% of the time.  (The other 20% they want
minimal, no-frills output, which is enabled by the default ctor.)
Then when people ask "how do I get pretty-printing?" the answer is

 new XMLOutputter("  ", true, true).output(document, System.out);

not

 XMLOutputter outputter = new XMLOutputter("  ", true);
 outputter.setTextNormalize(true);
 outputter.output(document, System.out);


Minor issues, I know, but we may as well deal with this now.

-- 
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/



More information about the jdom-interest mailing list