<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2655.35">
<TITLE>XMLOutputter & currentFormat</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>XMLFormat is very close to being "thread-friendly" ... I know that JDom does not attempt thread-safeness, but hear me out.</FONT></P>
<P><FONT SIZE=2>Once XMLOutputter is instantiated, and the defaultFormatter is set, then the "output" methods can be called any number of times concurrently without breaking things ... except for the "currentFormat". This may be changed if an Element has a "space" attribute.</FONT></P>
<P><FONT SIZE=2>The currentFormat is stored as an instance variable, and thus, if the data in one thread changes the current format, then all threads will take on the new format.</FONT></P>
<P><FONT SIZE=2>This is relatively easily corrected by having the format cascade down the element tree as the XML Is output.</FONT>
</P>
<P><FONT SIZE=2>This will/may break objects which extend the XMLOutputter....</FONT>
</P>
<P><FONT SIZE=2>Pro's:</FONT>
<BR><FONT SIZE=2> XMLOutputter needs only one instance per Format permutation, instead of one instance per thread.</FONT>
</P>
<P><FONT SIZE=2>Con's:</FONT>
<BR><FONT SIZE=2> Break classes which extend XMLOutputter (none in JDom, but may be outside).</FONT>
<BR><FONT SIZE=2> XMLOutputter is relatively "light" anyway, and the memory saved would be relatively small.</FONT>
</P>
<P><FONT SIZE=2>I have a patch available which makes the above change, and I have been using it myself.</FONT>
</P>
<P><FONT SIZE=2>Are attachments permitted on this list?</FONT>
</P>
<P><FONT SIZE=2>Rolf</FONT>
</P>
<BR>
</BODY>
</HTML>