Beispiel #1
0
  public void updateNodeName(String oldName, String newName) {
    // Update in the whole Tree
    if (!oldName.isEmpty() && !newName.isEmpty()) {

      Enumeration en = root.depthFirstEnumeration();

      while (en.hasMoreElements()) {
        DecisionTreeNode node = (DecisionTreeNode) en.nextElement();
        if (node.nodeName.compareTo(oldName) == 0) {
          node.nodeName = newName;
        }
      }
    }

    // Update in the added Node List
    ArrayList<String> nodesToBeAdded = new ArrayList<String>(addedNodes);
    addedNodes.clear();

    for (String node : nodesToBeAdded) {
      String[] arr = node.split(":");
      if (arr[1].compareTo(oldName) == 0) {
        addedNodes.add(arr[0] + ":" + newName + ":" + arr[2]);
      } else {
        addedNodes.add(node);
      }
    }

    // Update in the correctNode list
    correctNodes.put(newName, correctNodes.get(oldName));
    correctNodes.remove(oldName);
  }