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  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  		//System.out.println("CompositeNode.equals()");
34      if(!super.equals(o)) {
35        return false;
36      }
37      if (!(o instanceof CompositeNode)) {
38  			return false;
39  		}
40  		CompositeNode r = (CompositeNode) o;
41  
42  		return (childNode != null) ? childNode.equals(r.childNode)
43  						: (r.childNode == null);
44  	}
45  	
46  	public String toString() {
47  		StringBuffer buf = new StringBuffer();
48  		if(childNode != null) {
49  		 buf.append("CompositeNode("+childNode+")");
50  		} else {
51  			buf.append("CompositeNode(no child)");
52  		}
53  		buf.append(printNext());
54  		return buf.toString();
55  	}
56  }