1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.joran.action;
15
16 import org.xml.sax.Attributes;
17 import org.xml.sax.Locator;
18
19 import ch.qos.logback.core.joran.spi.ActionException;
20 import ch.qos.logback.core.joran.spi.InterpretationContext;
21 import ch.qos.logback.core.joran.spi.Interpreter;
22 import ch.qos.logback.core.spi.ContextAwareBase;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public abstract class Action extends ContextAwareBase {
39
40 public static final String NAME_ATTRIBUTE = "name";
41 public static final String KEY_ATTRIBUTE = "key";
42 public static final String VALUE_ATTRIBUTE = "value";
43 public static final String FILE_ATTRIBUTE = "file";
44 public static final String CLASS_ATTRIBUTE = "class";
45 public static final String PATTERN_ATTRIBUTE = "pattern";
46 public static final String SCOPE_ATTRIBUTE = "scope";
47
48
49 public static final String ACTION_CLASS_ATTRIBUTE = "actionClass";
50
51
52
53
54
55 public abstract void begin(InterpretationContext ic, String name,
56 Attributes attributes) throws ActionException;
57
58
59
60
61
62
63
64 public void body(InterpretationContext ic, String body)
65 throws ActionException {
66
67 }
68
69
70
71
72
73 public abstract void end(InterpretationContext ic, String name)
74 throws ActionException;
75
76 public String toString() {
77 return this.getClass().getName();
78 }
79
80 protected int getColumnNumber(InterpretationContext ic) {
81 Interpreter ji = ic.getJoranInterpreter();
82 Locator locator = ji.getLocator();
83 if (locator != null) {
84 return locator.getColumnNumber();
85 }
86 return -1;
87 }
88
89 protected int getLineNumber(InterpretationContext ic) {
90 Interpreter ji = ic.getJoranInterpreter();
91 Locator locator = ji.getLocator();
92 if (locator != null) {
93 return locator.getLineNumber();
94 }
95 return -1;
96 }
97
98 protected String getLineColStr(InterpretationContext ic) {
99 String line = "line: " + getLineNumber(ic) + ", column: "
100 + getColumnNumber(ic);
101 return line;
102 }
103 }