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