[jdom-interest] XMLOutputter newline and sockets

Steven D. Keens skeens at planetfred.com
Thu Aug 23 07:51:10 PDT 2001

I looked into the Format class idea a while back (but didn't publish it) and
decided it wasn't feasible in the current design. The biggest problem is
that the XMLOutputter writes directly to a stream.  If you want to make a
Format subclass (call it XMLFormat) then it should have the same interface
as java.text.Format.  The basic interface is that you pass in an object and
it returns a StringBuffer which is then written to the stream.  That's just
another step in the chain to output the text.  Since JDOM is supposed to be
fast, adding more overhead is probably the wrong way to go.

At the time I thought a better approach would be to have an output class
hierarchy but my real job kept harassing me, demanding some of my attention.
Then I forgot about it until now.  I haven't seen the idea mentioned before
so I would like to propose something now.  I propose we have different
classes for each type of formatting we want.  So there would be a
XMLRawOutputter, XMLCompressedOutputter, and a XMLPrettyOutputter, ...  The
reason I like this is that the current XMLOutputter implementation is a
pretty heavy class if you don't care about formatting.  There is a lot of
logic to support pretty printing.

Go ahead an criticize as you see fit.

Steven Keens                mailto:skeens at planetfred.com
Planetfred Inc.             http://www.planetfred.com
44 Byward Market, Suite 240, Ottawa, ON, K1N 7A2, Canada

The most exciting phrase in science, the one which heralds
new discoveries, is not "Eureka!", but "That's funny!"
                       -- Isaac Asimov

>-----Original Message-----
>From: jdom-interest-admin at jdom.org
>[mailto:jdom-interest-admin at jdom.org]On Behalf Of Jason Hunter
>Sent: Wednesday, August 22, 2001 18:43
>To: Steve Upton
>Cc: jdom-interest at jdom.org
>Subject: Re: [jdom-interest] XMLOutputter newline and sockets
>> I suspect that the best route would be something along the lines of a
>> method:
>>     setFormat(Format myFormat)
>> Or something similar. The format class could then include the existing
>> flags, and
>> new ones could be added without changes to the interface of the
>> class.
>I tend to think we should stop making whitespace, indents, and newlines
>separately tweakable and instead just provide the ability to do "raw",
>"pretty", and "compressed".  The difficulty is in what "pretty" means --
>trim or normalize, two spaces, four spaces, or indents, etc.
>To control your jdom-interest membership:
>r at yourhost.com

More information about the jdom-interest mailing list