public interface InfoAppend
StringBuilder buffer = new StringBuilder(100); anyInstance.infoAppend(buffer); buffer.append("some more information"); System.out.append(buffer);If this information should be stored it is possible persistent as reference of type
CharSequence
.
A reference which may changed the StringBuilder content should not be used.
infoAppend(StringBuilder)
.toString() builds a persistent String of this information. The copy of content is done here at least only.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
version
Version, history and license.
|
Modifier and Type | Method and Description |
---|---|
java.lang.CharSequence |
infoAppend(java.lang.StringBuilder u)
Appends or returns tan information about the instance.
|
static final java.lang.String version
java.lang.CharSequence infoAppend(java.lang.StringBuilder u)
StringBuilder u = new StringBulder(1000); u.append(something_else); myInstance.infoAppend(u); //uses this interface u.append(some_more); System.out.append(u); //output the information String savedInfo = u.toString(); //save permanent.Implementing pattern
QOverride public infoAppend(StringBuilder u) { if(u == null){ u = new StringBuilder(); } //it can be null! u.append(special_information).append(": ").append(somewhatElse); return u; }Contiguity with toString: It uses the same information, assembled in a StringBuilder:
QOverride public String toString(){ return infoAppend(null).toString()); }
u
- if not null then the info is appended to u, u is returned.