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