Classes which implement this interface can be appended directly to a StringBuffer
without first having to create a string representation.
This allows the elimination of intermediate strings when creating a
string representation of the object for display purposes. This is not the same
as Serializable - this is for human readable display purposes. It is the
same as the call to toString() , but appended to StringBuffers
without the intermediate String being created.
Any class which implements this should probably also override its
toString() method to something like
public String toString()
{
StringBuffer s = new StringBuffer();
appendTo(s,2);
return s.toString();
}
And may also want to use the AppenderHelper class for any internal objects
jack.basics.AppenderHelper.SINGLETON.append(s,obj,1);
in the appendTo method. This
will cut down on extraneous string production. The rationale is that
string production is seriously overdone, and the reduction of unnecessary
string creation is more likely to improve performance than the overheads
in the above call (especially as the AppenderHelper class is much faster than
StringBuffer in appending most data types). |