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.pattern.parser;
15  
16  public class CompositeNode extends SimpleKeywordNode {
17      Node childNode;
18  
19      CompositeNode(String keyword) {
20          super(Node.COMPOSITE_KEYWORD, keyword);
21  
22      }
23  
24      public Node getChildNode() {
25          return childNode;
26      }
27  
28      public void setChildNode(Node childNode) {
29          this.childNode = childNode;
30      }
31  
32      public boolean equals(Object o) {
33          if (!super.equals(o)) {
34              return false;
35          }
36          if (!(o instanceof CompositeNode)) {
37              return false;
38          }
39          CompositeNode r = (CompositeNode) o;
40  
41          return (childNode != null) ? childNode.equals(r.childNode) : (r.childNode == null);
42      }
43  
44      @Override
45      public int hashCode() {
46          return super.hashCode();
47      }
48  
49      public String toString() {
50          StringBuilder buf = new StringBuilder();
51          if (childNode != null) {
52              buf.append("CompositeNode(" + childNode + ")");
53          } else {
54              buf.append("CompositeNode(no child)");
55          }
56          buf.append(printNext());
57          return buf.toString();
58      }
59  }