1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.model.processor;
15
16 import ch.qos.logback.core.Context;
17 import ch.qos.logback.core.model.Model;
18 import ch.qos.logback.core.spi.ContextAwareBase;
19
20 abstract public class ModelHandlerBase extends ContextAwareBase {
21
22 public ModelHandlerBase(Context context) {
23 setContext(context);
24 }
25
26
27
28
29
30
31
32
33
34
35 protected Class<? extends Model> getSupportedModelClass() {
36
37 return Model.class;
38 }
39
40 protected boolean isSupportedModelType(Model model) {
41 Class<? extends Model> modelClass = getSupportedModelClass();
42 if (modelClass.isInstance(model)) {
43 return true;
44 } else {
45 addError("This handler can only handle models of type [" + modelClass + "]");
46 return false;
47 }
48 }
49
50 abstract public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException;
51
52 public void postHandle(ModelInterpretationContext mic, Model model) throws ModelHandlerException {
53
54 }
55
56 public String toString() {
57 return this.getClass().getName();
58 }
59
60 }