View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, 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.pattern.parser;
15  
16  import java.util.List;
17  
18  public class SimpleKeywordNode extends FormattingNode {
19  
20    List<String> optionList;
21  
22    SimpleKeywordNode(Object value) {
23      super(Node.SIMPLE_KEYWORD, value);
24    }
25  
26    protected  SimpleKeywordNode(int type, Object value) {
27      super(type, value);
28    }
29  
30    public List<String> getOptions() {
31      return optionList;
32    }
33  
34    public void setOptions(List<String> optionList) {
35      this.optionList = optionList;
36    }
37  
38    public boolean equals(Object o) {
39      // System.out.println("Keyword.equals()");
40      if (!super.equals(o)) {
41        return false;
42      }
43  
44      if (!(o instanceof SimpleKeywordNode)) {
45        return false;
46      }
47      SimpleKeywordNode r = (SimpleKeywordNode) o;
48  
49      return (optionList != null ? optionList.equals(r.optionList)
50          : r.optionList == null);
51    }
52  
53    public String toString() {
54      StringBuffer buf = new StringBuffer();
55      if (optionList == null) {
56        buf.append("KeyWord(" + value + "," + formatInfo + ")");
57      } else {
58        buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList
59            + ")");
60      }
61      buf.append(printNext());
62      return buf.toString();
63    }
64  }