1
2
3
4
5
6
7
8
9
10 package ch.qos.logback.core.pattern;
11
12 public class CompositeConverter<E> extends FormattingConverter<E> {
13
14 StringBuffer buf = new StringBuffer();
15 Converter<E> childConverter;
16
17 public String convert(E event) {
18 if (buf.capacity() > MAX_CAPACITY) {
19 buf = new StringBuffer(INITIAL_BUF_SIZE);
20 } else {
21 buf.setLength(0);
22 }
23
24 for (Converter<E> c = childConverter; c != null; c = c.next) {
25 c.write(buf, event);
26 }
27 return buf.toString();
28 }
29
30 public void setChildConverter(Converter<E> child) {
31 childConverter = child;
32 }
33
34 public String toString() {
35 StringBuffer buf = new StringBuffer();
36 buf.append("CompositeConverter<");
37
38 if(formattingInfo != null)
39 buf.append(formattingInfo);
40
41 if (childConverter != null) {
42 buf.append(", children: "+childConverter);
43 }
44 buf.append(">");
45 return buf.toString();
46 }
47 }