Changeset 9005
- Timestamp:
- 2005-02-10T16:47:46+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r8961 r9005 13 13 import java.util.Vector; 14 14 import java.util.Iterator; 15 import java.util.ArrayList; 16 15 17 //import java.util.Locale; 16 18 … … 106 108 public static final String NODE_NAME_ATT = "nodeName"; 107 109 public static final String NODE_TYPE_ATT = "nodeType"; 108 110 public static final String NODE_RANK_ATT = "rank"; 109 111 public static final String NODE_TYPE_ROOT = "root"; 110 112 public static final String NODE_TYPE_INTERNAL = "internal"; … … 514 516 return p; 515 517 } 518 public static Element createParameterDescription2(Document owner, 519 String id, 520 String display_name, 521 String type, 522 String default_value, 523 ArrayList option_ids, 524 ArrayList option_names) { 525 526 527 Element p = owner.createElement(PARAM_ELEM); 528 p.setAttribute(NAME_ATT, id); 529 p.setAttribute(TYPE_ATT, type); 530 p.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, display_name)); 531 if (default_value != null) { 532 p.setAttribute(DEFAULT_ATT, default_value); 533 } 534 if (option_ids!=null && option_names!=null) { 535 for (int i=0; i<option_ids.size(); i++) { 536 Element e = owner.createElement(PARAM_OPTION_ELEM); 537 e.setAttribute(NAME_ATT, (String)option_ids.get(i)); 538 e.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, (String)option_names.get(i))); 539 p.appendChild(e); 540 } 541 } 542 return p; 543 } 516 544 517 545 … … 535 563 } 536 564 537 565 public static int SORT_TYPE_STRING = 0; 566 public static int SORT_TYPE_INT = 1; 567 public static int SORT_TYPE_FLOAT = 2; 568 569 // sort type: 570 public static Element insertIntoOrderedList(Element parent_node, 571 String node_name, 572 Element start_from_elem, 573 Element new_elem, String sort_att, 574 boolean descending) 575 { 576 if (new_elem == null) return null; 577 System.err.println("+"); 578 Element cloned_elem = (Element)parent_node.getOwnerDocument().importNode(new_elem, true); 579 if (start_from_elem == null) { 580 parent_node.appendChild(cloned_elem); 581 return cloned_elem; 582 } 583 System.err.println("++"); 584 585 Node current_node = start_from_elem; 586 String insert_att = cloned_elem.getAttribute(sort_att); 587 String list_att = start_from_elem.getAttribute(sort_att); 588 while ((!descending && list_att.compareTo(insert_att)<0) || (descending && list_att.compareTo(insert_att)>0)) { 589 System.err.println("+++"); 590 current_node = current_node.getNextSibling(); 591 if (current_node == null) break; // end of the list 592 if (!current_node.getNodeName().equals(node_name)) { 593 continue; // not a valid node 594 } 595 list_att = ((Element)current_node).getAttribute(sort_att); 596 } 597 System.err.println("++++"); 598 599 parent_node.insertBefore(cloned_elem, current_node); 600 return cloned_elem; 601 } 602 538 603 539 604 /** Returns the appropriate language element from a display elem, … … 542 607 lang if neither lang is found, will return the first one it finds*/ 543 608 public static String getDisplayText(Element display, String name, 544 609 String lang, String lang_default) { 545 610 546 611 String def = null;
Note:
See TracChangeset
for help on using the changeset viewer.