[jdom-interest] XMLOutputter naming questions

Joseph Bowbeer jozart at csi.com
Sat Sep 30 15:09:08 PDT 2000


Alex Chaffee wrote:

>> - add a method for outputting a string.  This would just wrap the
normal output() in a  ByteArrayOutputStream.  Then we can use the same
formatter (and all its options) to output a (document or element) to a
(string or stream or writer). <<

Alex,

Once you've added output(whatever, Writer), do you need to add extra
string methods?  Can't the user just pass-in a StringWriter instead?

I'm not clear on all the encoding complications, but in addition to the
obligatory toString() method, StringWriter provides getBuffer() to
return the underlying StringBuffer -- which could be more efficient in
some situations.

If output directly to String is desired, I favor tagging the method name
with the return type, since Java refuses to differentiate based solely
on return type.  So if you must, I prefer:

 String outputString(Document d)
 String outputString(Element e)

On the other hand, I don't see any need to append 'Element' as in
'outputElement'.  I prefer:

 void output(Document d, OutputStream out)
 void output(Element d, OutputStream out)

Other votes:

 +1 for getChild[ren]
 +0 for getChildElement[s]
 -1 for getElement[s]

--
Joe Bowbeer






More information about the jdom-interest mailing list