View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.joran.conditional;
15  
16  import ch.qos.logback.core.spi.PropertyContainer;
17  import ch.qos.logback.core.util.OptionHelper;
18  
19  public class PropertyWrapperForScripts {
20  
21      PropertyContainer local;
22      PropertyContainer context;
23  
24      // this method is invoked by reflection in PropertyEvalScriptBuilder
25      public void setPropertyContainers(PropertyContainer local, PropertyContainer context) {
26          this.local = local;
27          this.context = context;
28      }
29  
30      public boolean isNull(String k) {
31          String val = OptionHelper.propertyLookup(k, local, context);
32          return (val == null);
33      }
34  
35      public boolean isDefined(String k) {
36          String val = OptionHelper.propertyLookup(k, local, context);
37          return (val != null);
38      }
39  
40      public String p(String k) {
41          return property(k);
42      }
43  
44      public String property(String k) {
45          String val = OptionHelper.propertyLookup(k, local, context);
46          if (val != null)
47              return val;
48          else
49              return "";
50      }
51  }