View Javadoc

1   package ch.qos.logback.core.pattern;
2   
3   import java.util.List;
4   
5   import ch.qos.logback.core.spi.LifeCycle;
6   
7   abstract public class DynamicConverter<E> extends FormattingConverter<E> implements LifeCycle {
8   
9     // Contains a list of option Strings.
10    private List optionList;
11    
12    /**
13     * Is this component active?
14     */
15    boolean started = false;
16  
17    /**
18     * Components that depend on options passed during configuration can override this method
19     * in order to make appropriate use of those options. For simpler components, the trivial implementation 
20     * found in this abstract class will be sufficient.
21     */
22    public void start() {
23      started = true;
24    }
25    
26    public void stop() {
27      started = false;
28    }
29    
30    public boolean isStarted() {
31      return started;
32    }
33    
34    public void setOptionList(List optionList) {
35      this.optionList = optionList;
36    }
37    
38    /**
39     * Return the first option passed to this component. The returned value
40     * may be null if there are no options.
41     * 
42     * @return First option, may be null.
43     */
44    protected String getFirstOption() {
45      if(optionList == null || optionList.size() == 0) {
46        return null;
47      } else {
48        return (String) optionList.get(0);
49      }
50    }
51    
52    protected List getOptionList() {
53      return optionList;
54    }
55  }