Revision 5311
Added by daigle about 14 years ago
NodeRecord.java | ||
---|---|---|
32 | 32 |
* A utility class that encapsulates a node and its data |
33 | 33 |
*/ |
34 | 34 |
public class NodeRecord { |
35 |
private long nodeid = -1; |
|
36 |
private long parentnodeid = -1; |
|
37 |
private long nodeindex = -1; |
|
38 |
private String nodename = null; |
|
39 |
private String nodeprefix = null; |
|
40 |
private String nodetype = null; |
|
41 |
private String nodedata = null; |
|
42 |
private float nodedatanumerical = -1; |
|
35 |
private long _nodeid = -1;
|
|
36 |
private long _parentnodeid = -1;
|
|
37 |
private long _nodeindex = -1;
|
|
38 |
private String _nodename = null;
|
|
39 |
private String _nodeprefix = null;
|
|
40 |
private String _nodetype = null;
|
|
41 |
private String _nodedata = null;
|
|
42 |
private float _nodedatanumerical = -1;
|
|
43 | 43 |
private Logger logMetacat = Logger.getLogger(NodeRecord.class); |
44 | 44 |
|
45 | 45 |
/** |
... | ... | |
48 | 48 |
public NodeRecord(long nodeid, long parentnodeid, long nodeindex, |
49 | 49 |
String nodetype, String nodename, String nodeprefix, |
50 | 50 |
String nodedata) { |
51 |
this.nodeid = nodeid;
|
|
52 |
this.parentnodeid = parentnodeid;
|
|
53 |
this.nodeindex = nodeindex;
|
|
54 |
this.nodename = nodename;
|
|
55 |
this.nodeprefix = nodeprefix;
|
|
56 |
this.nodetype = nodetype;
|
|
57 |
this.nodedata = nodedata;
|
|
51 |
setNodeId(nodeid);
|
|
52 |
setParentNodeId(parentnodeid);
|
|
53 |
setNodeIndex(nodeindex);
|
|
54 |
setNodeName(nodename);
|
|
55 |
setNodePrefix(nodeprefix);
|
|
56 |
setNodeType(nodetype);
|
|
57 |
setNodeData(nodedata);
|
|
58 | 58 |
} |
59 | 59 |
|
60 |
public NodeRecord(long nodeid, long parentnodeid, long nodeindex, String nodetype, |
|
61 |
String nodename, String nodeprefix, String nodedata, float nodedatanumerical) { |
|
62 |
setNodeId(nodeid); |
|
63 |
setParentNodeId(parentnodeid); |
|
64 |
setNodeIndex(nodeindex); |
|
65 |
setNodeName(nodename); |
|
66 |
setNodePrefix(nodeprefix); |
|
67 |
setNodeType(nodetype); |
|
68 |
setNodeData(nodedata); |
|
69 |
setNodeDataNumerical(nodedatanumerical); |
|
70 |
} |
|
60 | 71 |
|
61 |
public NodeRecord(long nodeid, long parentnodeid, long nodeindex, |
|
62 |
String nodetype, String nodename, String nodeprefix, |
|
63 |
String nodedata, float nodedatanumerical) { |
|
64 |
this.nodeid = nodeid; |
|
65 |
this.parentnodeid = parentnodeid; |
|
66 |
this.nodeindex = nodeindex; |
|
67 |
this.nodename = nodename; |
|
68 |
this.nodeprefix = nodeprefix; |
|
69 |
this.nodetype = nodetype; |
|
70 |
this.nodedata = nodedata; |
|
71 |
this.nodedatanumerical = nodedatanumerical; |
|
72 |
} |
|
73 |
|
|
74 |
/** Get functions*/ |
|
72 |
/** Get functions */ |
|
75 | 73 |
public long getNodeId() |
76 | 74 |
{ |
77 |
return nodeid; |
|
75 |
return _nodeid;
|
|
78 | 76 |
} |
79 | 77 |
|
80 | 78 |
public long getParentNodeId() |
81 | 79 |
{ |
82 |
return parentnodeid; |
|
80 |
return _parentnodeid;
|
|
83 | 81 |
} |
84 | 82 |
|
85 | 83 |
public long getNodeIndex() |
86 | 84 |
{ |
87 |
return nodeindex; |
|
85 |
return _nodeindex;
|
|
88 | 86 |
} |
89 | 87 |
|
90 | 88 |
public String getNodeName() |
91 | 89 |
{ |
92 |
return nodename; |
|
90 |
return _nodename;
|
|
93 | 91 |
} |
94 | 92 |
|
95 | 93 |
public String getNodeType() |
96 | 94 |
{ |
97 |
return nodetype; |
|
95 |
return _nodetype;
|
|
98 | 96 |
} |
99 | 97 |
|
100 | 98 |
public String getNodePrefix() |
101 | 99 |
{ |
102 |
return nodeprefix; |
|
100 |
return _nodeprefix;
|
|
103 | 101 |
} |
104 | 102 |
|
105 | 103 |
public String getNodeData() |
106 | 104 |
{ |
107 |
return nodedata; |
|
105 |
return _nodedata;
|
|
108 | 106 |
} |
109 | 107 |
|
110 | 108 |
public float getNodeDataNumerical() |
111 | 109 |
{ |
112 |
return nodedatanumerical; |
|
110 |
return _nodedatanumerical;
|
|
113 | 111 |
} |
114 | 112 |
|
115 | 113 |
/** Setter methods **/ |
... | ... | |
119 | 117 |
* |
120 | 118 |
* @param id the new value of the id |
121 | 119 |
*/ |
122 |
public void setNodeId (long id){ |
|
123 |
this.nodeid = id;
|
|
120 |
public void setNodeId (long id) {
|
|
121 |
_nodeid = id;
|
|
124 | 122 |
} |
125 | 123 |
|
126 | 124 |
/** |
... | ... | |
128 | 126 |
* |
129 | 127 |
* @param parentid the new value of the parent id |
130 | 128 |
*/ |
131 |
public void setParentNodeId (long parentid){ |
|
132 |
this.parentnodeid = parentid;
|
|
129 |
public void setParentNodeId (long parentid) {
|
|
130 |
_parentnodeid = parentid;
|
|
133 | 131 |
} |
134 | 132 |
|
135 | 133 |
/** |
... | ... | |
137 | 135 |
* |
138 | 136 |
* @param name the new value of the node name |
139 | 137 |
*/ |
140 |
public void setNodeName (String name){ |
|
141 |
this.nodename = name; |
|
138 |
public void setNodeName (String name) { |
|
139 |
if (name != null) { |
|
140 |
_nodename = name.trim(); |
|
141 |
} else { |
|
142 |
_nodename = null; |
|
143 |
} |
|
142 | 144 |
} |
143 | 145 |
|
144 | 146 |
/** |
... | ... | |
146 | 148 |
* |
147 | 149 |
* @param prefix the new value of the node prefix |
148 | 150 |
*/ |
149 |
public void setNodePrefix (String prefix){ |
|
150 |
this.nodeprefix = prefix; |
|
151 |
public void setNodePrefix (String prefix) { |
|
152 |
if (prefix != null) { |
|
153 |
_nodeprefix = prefix.trim(); |
|
154 |
} else { |
|
155 |
_nodeprefix = null; |
|
156 |
} |
|
151 | 157 |
} |
152 | 158 |
|
153 | 159 |
/** |
... | ... | |
155 | 161 |
* |
156 | 162 |
* @param index the new value of the node index |
157 | 163 |
*/ |
158 |
public void setNodeIndex (long index){ |
|
159 |
this.nodeindex = index;
|
|
164 |
public void setNodeIndex (long index) {
|
|
165 |
_nodeindex = index;
|
|
160 | 166 |
} |
161 | 167 |
|
162 | 168 |
/** |
... | ... | |
164 | 170 |
* |
165 | 171 |
* @param type the new value of the node type |
166 | 172 |
*/ |
167 |
public void setNodeType (String type){ |
|
168 |
this.nodetype = type; |
|
173 |
public void setNodeType (String type) { |
|
174 |
if (type != null) { |
|
175 |
_nodetype = type.trim(); |
|
176 |
} else { |
|
177 |
_nodetype = null; |
|
178 |
} |
|
169 | 179 |
} |
170 | 180 |
|
171 | 181 |
/** |
... | ... | |
173 | 183 |
* |
174 | 184 |
* @param data the new value of the node data |
175 | 185 |
*/ |
176 |
public void setNodeData (String data){ |
|
177 |
this.nodedata = data; |
|
186 |
public void setNodeData (String data) { |
|
187 |
if (data != null) { |
|
188 |
_nodedata = data.trim(); |
|
189 |
} else { |
|
190 |
_nodedata = null; |
|
191 |
} |
|
178 | 192 |
} |
179 | 193 |
|
180 | 194 |
/** |
... | ... | |
183 | 197 |
* @param datanumerical the new value of the numerical node data |
184 | 198 |
*/ |
185 | 199 |
public void setNodeDataNumerical (float datanumerical){ |
186 |
this.nodedatanumerical = datanumerical;
|
|
200 |
_nodedatanumerical = datanumerical;
|
|
187 | 201 |
} |
188 | 202 |
|
189 | 203 |
/** Method compare two records */ |
190 | 204 |
public boolean contentEquals(NodeRecord record) |
191 | 205 |
{ |
192 | 206 |
boolean flag = true; |
193 |
logMetacat.info("First nodetype: "+this.nodetype);
|
|
194 |
logMetacat.info("Second nodetype: "+record.getNodeType());
|
|
195 |
logMetacat.info("First nodename: "+this.nodename);
|
|
196 |
logMetacat.info("Second nodename: "+record.getNodeName());
|
|
197 |
logMetacat.info("First nodeprefix: "+this.nodeprefix);
|
|
198 |
logMetacat.info("Second nodeprefix: "+record.getNodePrefix());
|
|
199 |
logMetacat.info("First nodedata: "+this.nodedata);
|
|
200 |
logMetacat.info("Second nodedata: "+record.getNodeData());
|
|
201 |
if ((this.nodename == null && record.getNodeName() != null) ||
|
|
202 |
(this.nodename != null && record.getNodeName() == null) ||
|
|
203 |
(this.nodename != null && record.getNodeName() != null &&
|
|
204 |
!(this.nodename).equals(record.getNodeName())))
|
|
207 |
logMetacat.info("First nodetype: " + _nodetype);
|
|
208 |
logMetacat.info("Second nodetype: " + record.getNodeType());
|
|
209 |
logMetacat.info("First nodename: " + _nodename);
|
|
210 |
logMetacat.info("Second nodename: " + record.getNodeName());
|
|
211 |
logMetacat.info("First nodeprefix: " + _nodeprefix);
|
|
212 |
logMetacat.info("Second nodeprefix: " + record.getNodePrefix());
|
|
213 |
logMetacat.info("First nodedata: " + _nodedata);
|
|
214 |
logMetacat.info("Second nodedata: " + record.getNodeData());
|
|
215 |
if ((_nodename == null && record.getNodeName() != null) ||
|
|
216 |
(_nodename != null && record.getNodeName() == null) ||
|
|
217 |
(_nodename != null && record.getNodeName() != null &&
|
|
218 |
!(_nodename).equals(record.getNodeName())))
|
|
205 | 219 |
{ |
206 | 220 |
//compare nodename |
207 | 221 |
flag = false; |
208 | 222 |
} |
209 |
else if ((this.nodetype == null && record.getNodeType() != null) ||
|
|
210 |
(this.nodetype != null && record.getNodeType() == null) ||
|
|
211 |
(this.nodetype != null && record.getNodeType() != null &&
|
|
212 |
!(this.nodetype).equals(record.getNodeType())))
|
|
223 |
else if ((_nodetype == null && record.getNodeType() != null) ||
|
|
224 |
(_nodetype != null && record.getNodeType() == null) ||
|
|
225 |
(_nodetype != null && record.getNodeType() != null &&
|
|
226 |
!(_nodetype).equals(record.getNodeType())))
|
|
213 | 227 |
{ |
214 | 228 |
// compare node type |
215 | 229 |
flag = false; |
216 | 230 |
} |
217 |
else if ((this.nodeprefix == null && record.getNodePrefix() != null) ||
|
|
218 |
(this.nodeprefix != null && record.getNodePrefix() == null) ||
|
|
219 |
(this.nodeprefix != null && record.getNodePrefix() != null &&
|
|
220 |
!(this.nodeprefix).equals(record.getNodePrefix())))
|
|
231 |
else if ((_nodeprefix == null && record.getNodePrefix() != null) ||
|
|
232 |
(_nodeprefix != null && record.getNodePrefix() == null) ||
|
|
233 |
(_nodeprefix != null && record.getNodePrefix() != null &&
|
|
234 |
!(_nodeprefix).equals(record.getNodePrefix())))
|
|
221 | 235 |
{ |
222 | 236 |
// compare node prefix |
223 | 237 |
flag = false; |
224 | 238 |
} |
225 |
else if ((this.nodedata == null && record.getNodeData() != null) ||
|
|
226 |
(this.nodedata != null && record.getNodeData() == null) ||
|
|
227 |
(this.nodedata != null && record.getNodeData() != null &&
|
|
228 |
!(this.nodedata).equals(record.getNodeData())))
|
|
239 |
else if ((_nodedata == null && record.getNodeData() != null) ||
|
|
240 |
(_nodedata != null && record.getNodeData() == null) ||
|
|
241 |
(_nodedata != null && record.getNodeData() != null &&
|
|
242 |
!(_nodedata).equals(record.getNodeData())))
|
|
229 | 243 |
{ |
230 | 244 |
// compare node data |
231 | 245 |
flag = false; |
Also available in: Unified diff
Merge 1.9.2 changes back into the trunk