1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.joran.action;
15
16
17 import org.xml.sax.Attributes;
18
19 import ch.qos.logback.core.joran.spi.InterpretationContext;
20 import ch.qos.logback.core.joran.util.PropertySetter;
21
22
23
24 public class ParamAction extends Action {
25 static String NO_NAME = "No name attribute in <param> element";
26 static String NO_VALUE = "No name attribute in <param> element";
27 boolean inError = false;
28
29 public void begin(
30 InterpretationContext ec, String localName, Attributes attributes) {
31 String name = attributes.getValue(NAME_ATTRIBUTE);
32 String value = attributes.getValue(VALUE_ATTRIBUTE);
33
34 if (name == null) {
35 inError = true;
36 addError(NO_NAME);
37 return;
38 }
39
40 if (value == null) {
41 inError = true;
42 addError(NO_VALUE);
43 return;
44 }
45
46
47 value = value.trim();
48
49 Object o = ec.peekObject();
50 PropertySetter propSetter = new PropertySetter(o);
51 propSetter.setContext(context);
52 value = ec.subst(value);
53
54
55 name = ec.subst(name);
56
57
58
59 propSetter.setProperty(name, value);
60 }
61
62 public void end(InterpretationContext ec, String localName) {
63 }
64
65 public void finish(InterpretationContext ec) {
66 }
67 }