1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.pattern.parser;
15
16 public class Node {
17 static final int LITERAL = 0;
18 static final int KEYWORD = 1;
19 static final int COMPOSITE = 2;
20
21 final int type;
22 final Object value;
23 Node next;
24
25 Node(int type) {
26 this(type, null);
27 }
28
29 Node(int type, Object value) {
30 this.type = type;
31 this.value = value;
32 }
33
34
35
36
37 public int getType() {
38 return type;
39 }
40
41
42
43
44 public Object getValue() {
45 return value;
46 }
47
48 public Node getNext() {
49 return next;
50 }
51
52 public void setNext(Node next) {
53 this.next = next;
54 }
55
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
59 }
60 if (!(o instanceof Node)) {
61 return false;
62 }
63 Node r = (Node) o;
64
65 return (type == r.type)
66 && (value != null ? value.equals(r.value) : r.value == null)
67 && (next != null ? next.equals(r.next) : r.next == null);
68 }
69
70 String printNext() {
71 if (next != null) {
72 return " -> " + next;
73 } else {
74 return "";
75 }
76 }
77
78 public String toString() {
79 StringBuffer buf = new StringBuffer();
80 switch (type) {
81 case LITERAL:
82 buf.append("LITERAL(" + value + ")");
83 break;
84 default:
85 buf.append(super.toString());
86 }
87
88 buf.append(printNext());
89
90 return buf.toString();
91 }
92 }