01: /*
02: * This is free software, licensed under the Gnu Public License (GPL)
03: * get a copy from <http://www.gnu.org/licenses/gpl.html>
04: */
05: package henplus.util;
06:
07: /**
08: * FIXME: removeme.
09: *
10: * @author <a href="mailto:martin.grotzke@javakaffee.de">Martin Grotzke</a>
11: * @version $Id: StringAppender.java,v 1.3 2004/05/31 10:48:22 hzeller Exp $
12: */
13: public final class StringAppender {
14:
15: private static StringBuffer _sb;
16: private static StringAppender _instance;
17:
18: private StringAppender() {
19: _sb = new StringBuffer();
20: }
21:
22: public static final StringAppender getInstance() {
23: if (_instance == null)
24: _instance = new StringAppender();
25: return _instance;
26: }
27:
28: public static StringAppender start(String value) {
29: if (_instance == null)
30: _instance = new StringAppender();
31: _sb.append(value);
32: return _instance;
33: }
34:
35: public StringAppender append(String value) {
36: _sb.append(value);
37: return this ;
38: }
39:
40: public StringAppender append(int value) {
41: _sb.append(value);
42: return this ;
43: }
44:
45: public String toString() {
46: String result = _sb.toString();
47: _sb.delete(0, _sb.length());
48: return result;
49: }
50:
51: }
|