1 package es.inteco.eni.xml;
2
3 import java.util.Iterator;
4 import java.util.LinkedHashMap;
5 import java.util.Map;
6
7 import org.xml.sax.Attributes;
8
9
10
11
12
13
14
15 public class XmlNode {
16
17
18
19
20 private String uri;
21
22
23
24 private String qName;
25
26
27
28 private String lName;
29
30
31
32 private String value;
33
34
35
36 private Attributes attributes;
37
38
39
40 private Map<String, XmlNode> childs = new LinkedHashMap<String, XmlNode>();
41
42
43
44
45 private XmlNode parent;
46
47
48
49
50 private Integer deep;
51
52
53
54 private Integer totalLeafDescendants;
55
56
57
58
59 public String getUri() {
60 return uri;
61 }
62
63
64
65
66 public void setUri(String uri) {
67 this.uri = uri;
68 }
69
70
71
72
73 public String getqName() {
74 return qName;
75 }
76
77
78
79
80 public void setqName(String qName) {
81 this.qName = qName;
82 }
83
84
85
86
87 public String getlName() {
88 return lName;
89 }
90
91
92
93
94 public void setlName(String lName) {
95 this.lName = lName;
96 }
97
98
99
100
101 public Attributes getAttributes() {
102 return attributes;
103 }
104
105
106
107
108 public void setAttributes(Attributes attributes) {
109 this.attributes = attributes;
110 }
111
112
113
114
115 public Map<String, XmlNode> getChilds() {
116 return childs;
117 }
118
119
120
121
122 public void setChilds(Map<String, XmlNode> childs) {
123 this.childs = childs;
124 }
125
126
127
128
129
130 public XmlNode getParent() {
131 return parent;
132 }
133
134
135
136
137 public void setParent(XmlNode parent) {
138 this.parent = parent;
139 }
140
141
142
143
144 public Integer getDeep() {
145 return deep;
146 }
147
148
149
150
151 public void setDeep(Integer deep) {
152 this.deep = deep;
153 }
154
155
156
157
158 public String getValue() {
159 return value;
160 }
161
162
163
164
165 public void setValue(String value) {
166 this.value = value;
167 }
168
169
170
171
172 public Integer getTotalLeafDescendants() {
173 Integer result = this.totalLeafDescendants;
174 if(result==null){
175 result=0;
176 Iterator<String> it = childs.keySet().iterator();
177 if(childs.size()==0){
178 result++;
179 }
180 while(it.hasNext()){
181 String nodeId = it.next();
182 result+=childs.get(nodeId).getTotalLeafDescendants();
183 }
184 this.totalLeafDescendants = result;
185 }
186
187 return result;
188 }
189
190
191
192
193 public void setTotalDescendants(Integer totalLeafDescendants) {
194 this.totalLeafDescendants = totalLeafDescendants;
195 }
196 }