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.PropertyModel;
21  
22  
23  
24  
25  
26  
27  
28  public class PropertyAction extends BaseModelAction {
29  
30      static final String RESOURCE_ATTRIBUTE = "resource";
31  
32      @Override
33      protected boolean validPreconditions(SaxEventInterpretationContext interpretationContext, String localName,
34              Attributes attributes) {
35          if ("substitutionProperty".equals(localName)) {
36              addWarn("[substitutionProperty] element has been deprecated. Please use the [variable] element instead.");
37          }
38          return true;
39      }
40  
41      @Override
42      protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name,
43              Attributes attributes) {
44          PropertyModel propertyModel = new PropertyModel();
45          propertyModel.setName(attributes.getValue(NAME_ATTRIBUTE));
46          propertyModel.setValue(attributes.getValue(VALUE_ATTRIBUTE));
47          propertyModel.setFile(attributes.getValue(FILE_ATTRIBUTE));
48          propertyModel.setResource(attributes.getValue(RESOURCE_ATTRIBUTE));
49          propertyModel.setScopeStr(attributes.getValue(SCOPE_ATTRIBUTE));
50          return propertyModel;
51      }
52  
53  }