1
2
3
4
5
6
7
8
9
10
11public
12class ToString<E>
13 extends Accumulate<E, String> {
14
15 private
16 StringBuffer result;
17
18 private
19 String separator,last;
20
21 private
22 boolean empty;
23
24
25
26
27
28
29
30
31
32
33 public
34 ToString( String first,
35 String separator,
36 String last )
37 {
38 result = new StringBuffer(first);
39 this.separator = separator;
40 this.last = last;
41 empty = true;
42 }
43
44
45
46 public
47 void process(E element)
48 {
49 if ( ! empty ) {
50 result.append(separator);
51 }
52 result.append(element.toString());
53 empty = false;
54 }
55
56
57
58 public
59 String getResult()
60 {
61 result.append(last);
62
63
64 return
65 result.toString();
66 }
67}