Exemple #1
0
  private static Key loadKey(org.w3c.dom.Element keyElement) {
    Key key = new Key();

    String visibility = keyElement.getAttribute("visibility").trim();
    if (visibility.equals("open")) {
      key.visibility = VIS_OPEN;
    } else if (visibility.equals("advanced")) {
      key.visibility = VIS_ADVANCED;
    } else if (visibility.equals("hidden")) {
      key.visibility = VIS_HIDDEN;
    }

    java.util.HashMap map = parseSingleNode(keyElement);

    org.w3c.dom.Element nameElement = (org.w3c.dom.Element) map.get("name");
    if (nameElement != null) {
      org.w3c.dom.Text textNode = (org.w3c.dom.Text) parseSingleNode(nameElement).get("text");
      if (textNode != null) {
        key.name = textNode.getData().trim();
      }
    }

    org.w3c.dom.Element valueElement = (org.w3c.dom.Element) map.get("value");
    if (valueElement != null) {
      org.w3c.dom.Element listElement =
          (org.w3c.dom.Element) parseSingleNode(valueElement).get("list");
      if (listElement != null) {
        key.valueList = new java.util.ArrayList();
        java.util.ArrayList items = (java.util.ArrayList) parseSingleNode(listElement).get("items");
        if (items != null) {
          for (java.util.Iterator iter = items.iterator(); iter.hasNext(); ) {
            org.w3c.dom.Element itemElement = (org.w3c.dom.Element) iter.next();
            if (itemElement != null) {
              org.w3c.dom.Text textNode =
                  (org.w3c.dom.Text) parseSingleNode(itemElement).get("text");
              if (textNode != null) {
                key.valueList.add(textNode.getData().trim());
              }
            }
          }
        }
      } else {
        org.w3c.dom.Text textNode = (org.w3c.dom.Text) parseSingleNode(valueElement).get("text");
        if (textNode != null) {
          key.value = textNode.getData().trim();
        }
      }
    }

    java.util.ArrayList keys = (java.util.ArrayList) map.get("keys");
    if (keys != null) {
      for (java.util.Iterator iter = keys.iterator(); iter.hasNext(); ) {
        org.w3c.dom.Element subKeyElement = (org.w3c.dom.Element) iter.next();
        if (subKeyElement != null) {
          if (key.subKeys == null) {
            key.subKeys = new java.util.HashMap();
          }
          Key subKey = loadKey(subKeyElement);
          if ((subKey != null) && (subKey.name != null)) {
            key.subKeys.put(subKey.name, subKey);
          }
        }
      }
    }

    return key;
  }
Exemple #2
0
 private static void _setVisibility(String keyName, int visibility) {
   Key key = root.getSubKey(keyName);
   if (key != null) {
     key.visibility = visibility;
   }
 }