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
18 import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
19 import ch.qos.logback.core.model.Model;
20 import ch.qos.logback.core.model.StatusListenerModel;
21 import ch.qos.logback.core.status.StatusListener;
22 import ch.qos.logback.core.util.OptionHelper;
23
24 public class StatusListenerAction extends BaseModelAction {
25
26 boolean inError = false;
27 Boolean effectivelyAdded = null;
28 StatusListener statusListener = null;
29
30 @Override
31 protected boolean validPreconditions(SaxEventInterpretationContext interpretationContext, String name,
32 Attributes attributes) {
33 String className = attributes.getValue(CLASS_ATTRIBUTE);
34 if (OptionHelper.isNullOrEmpty(className)) {
35 addError("Missing class name for statusListener. Near [" + name + "] line "
36 + getLineNumber(interpretationContext));
37 return false;
38 }
39 return true;
40 }
41
42 @Override
43 protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name,
44 Attributes attributes) {
45 StatusListenerModel statusListenerModel = new StatusListenerModel();
46 statusListenerModel.setClassName(attributes.getValue(CLASS_ATTRIBUTE));
47 return statusListenerModel;
48 }
49
50 }