1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.pattern;
15
16 import java.util.List;
17
18 import ch.qos.logback.core.Context;
19 import ch.qos.logback.core.spi.ContextAware;
20 import ch.qos.logback.core.spi.ContextAwareBase;
21 import ch.qos.logback.core.spi.LifeCycle;
22 import ch.qos.logback.core.status.Status;
23
24 abstract public class DynamicConverter<E> extends FormattingConverter<E>
25 implements LifeCycle, ContextAware {
26
27 ContextAwareBase cab = new ContextAwareBase(this);
28
29
30 private List<String> optionList;
31
32
33
34
35 boolean started = false;
36
37
38
39
40
41
42
43 public void start() {
44 started = true;
45 }
46
47 public void stop() {
48 started = false;
49 }
50
51 public boolean isStarted() {
52 return started;
53 }
54
55 public void setOptionList(List<String> optionList) {
56 this.optionList = optionList;
57 }
58
59
60
61
62
63
64
65 public String getFirstOption() {
66 if (optionList == null || optionList.size() == 0) {
67 return null;
68 } else {
69 return optionList.get(0);
70 }
71 }
72
73 protected List<String> getOptionList() {
74 return optionList;
75 }
76
77 public void setContext(Context context) {
78 cab.setContext(context);
79 }
80
81 public Context getContext() {
82 return cab.getContext();
83 }
84
85 public void addStatus(Status status) {
86 cab.addStatus(status);
87 }
88
89 public void addInfo(String msg) {
90 cab.addInfo(msg);
91 }
92
93 public void addInfo(String msg, Throwable ex) {
94 cab.addInfo(msg, ex);
95 }
96
97 public void addWarn(String msg) {
98 cab.addWarn(msg);
99 }
100
101 public void addWarn(String msg, Throwable ex) {
102 cab.addWarn(msg, ex);
103 }
104
105 public void addError(String msg) {
106 cab.addError(msg);
107 }
108
109 public void addError(String msg, Throwable ex) {
110 cab.addError(msg, ex);
111 }
112 }