1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.config;
18
19 import org.apache.logging.log4j.core.config.plugins.PluginType;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26
27
28
29 public class Node {
30
31 private final Node parent;
32 private final String name;
33 private String value;
34 private final PluginType type;
35 private final Map<String, String> attributes = new HashMap<String, String>();
36 private final List<Node> children = new ArrayList<Node>();
37 private Object object;
38
39
40
41
42
43
44
45
46
47
48 public Node(Node parent, String name, PluginType type) {
49 this.parent = parent;
50 this.name = name;
51 this.type = type;
52 }
53
54 public Node() {
55 this.parent = null;
56 this.name = null;
57 this.type = null;
58 }
59
60 public Map<String, String> getAttributes() {
61 return attributes;
62 }
63
64 public List<Node> getChildren() {
65 return children;
66 }
67
68 public boolean hasChildren() {
69 return children.size() > 0;
70 }
71
72 public String getValue() {
73 return value;
74 }
75
76 public void setValue(String value) {
77 this.value = value;
78 }
79
80 public Node getParent() {
81 return parent;
82 }
83
84 public String getName() {
85 return name;
86 }
87
88 public boolean isRoot() {
89 return parent == null;
90 }
91
92 public void setObject(Object obj) {
93 object = obj;
94 }
95
96 public Object getObject() {
97 return object;
98 }
99
100 public PluginType getType() {
101 return type;
102 }
103
104 @Override
105 public String toString() {
106 if (object == null) {
107 return "null";
108 }
109 return type.isObjectPrintable() ? object.toString() :
110 type.getPluginClass().getName() + " with name " + name;
111 }
112 }