- Timestamp:
- 2003-10-17T04:50:35+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java
r5581 r5672 62 62 extends DefaultMutableTreeNode { 63 63 64 static final public int DOM = 0; 65 static final public int GREENSTONE = 1; 66 static final public int TEXT = 2; 67 64 68 private String element_name = null; 65 69 private String default_value = null; … … 221 225 } 222 226 223 public GValueNode getValue(String value) { 224 if(default_value != null) { 225 return this; 226 } 227 if(children == null) { 228 map(); 229 } 230 for(int i = 0; i < children.size(); i++) { 231 GValueNode child = (GValueNode) children.get(i); 232 if(child.toString(false).equalsIgnoreCase(value)) { 233 return child; 234 } 235 } 236 return null; 237 } 227 public GValueNode getValue(String value) { 228 ///ystem.err.println("GValueNode.getValue(" + value + ")"); 229 if(default_value != null) { 230 return this; 231 } 232 if(children == null) { 233 map(); 234 } 235 for(int i = 0; i < children.size(); i++) { 236 GValueNode child = (GValueNode) children.get(i); 237 ///ystem.err.println("Comparing value and '" + child.toString(GValueNode.DOM)); 238 if(child.toString(GValueNode.DOM).equalsIgnoreCase(value)) { 239 return child; 240 } 241 } 242 return null; 243 } 238 244 239 245 /** Adds <I>child</I> to the receiever at <I>index</I>. <I>child</I> will … … 321 327 */ 322 328 public String toString() { 323 return toString( true);329 return toString(GValueNode.TEXT); 324 330 } 325 331 326 public String toString( boolean as_text) {332 public String toString(int decode_type) { 327 333 if(default_value != null) { 328 334 return default_value; … … 332 338 String result = null; 333 339 if(name.equals("Subject")) { 334 if(as_text) { 335 result = Codec.transform(MSMUtils.getValue(element), Codec.GREENSTONE_TO_TEXT); 336 } 337 else { 338 result = MSMUtils.getValue(element); 339 } 340 result = MSMUtils.getValue(element); 341 switch(decode_type) { 342 case GValueNode.GREENSTONE: 343 // We want this as greenstone format 344 ///ystem.err.print(result); 345 result = Codec.transform(result, Codec.DOM_TO_GREENSTONE); 346 ///ystem.err.println(" -> D2G decode -> " + result); 347 break; 348 case GValueNode.TEXT: 349 ///ystem.err.print(result); 350 result = Codec.transform(result, Codec.DOM_TO_TEXT); 351 ///ystem.err.println(" -> D2T decode -> " + result); 352 break; 353 default: 354 ///ystem.err.println(result + " -> nothing to do."); 355 } 340 356 } 341 357 else if(name.equals("AssignedValues")) { … … 364 380 public void remove(MutableTreeNode node) { 365 381 children.remove(node); 366 parent = null;382 node.setParent(null); 367 383 // Remove from DOM 368 Node child_node = (Node) userObject;369 Node parent_node = child_ node.getParentNode();370 parent_node.removeChild(child_ node);384 Element child_element = ((GValueNode)node).getElement(); 385 Node parent_node = child_element.getParentNode(); 386 parent_node.removeChild(child_element); 371 387 } 372 388
Note:
See TracChangeset
for help on using the changeset viewer.