private static Map getAttributeMap()

in appengine-plugins-core/src/main/java/com/google/cloud/tools/appengine/AppEngineDescriptor.java [162:189]


  private static Map<String, String> getAttributeMap(
      Node parent, String nodeName, String keyAttributeName, String valueAttributeName)
      throws AppEngineException {

    Map<String, String> nameValueAttributeMap = new HashMap<>();
    if (parent.hasChildNodes()) {
      for (int i = 0; i < parent.getChildNodes().getLength(); i++) {
        Node child = parent.getChildNodes().item(i);
        NamedNodeMap attributeMap = child.getAttributes();

        if (nodeName.equals(child.getNodeName()) && attributeMap != null) {
          Node keyNode = attributeMap.getNamedItem(keyAttributeName);

          if (keyNode != null) {
            Node valueNode = attributeMap.getNamedItem(valueAttributeName);
            try {
              nameValueAttributeMap.put(keyNode.getTextContent(), valueNode.getTextContent());
            } catch (DOMException ex) {
              throw new AppEngineException(
                  "Failed to parse value from attribute node " + keyNode.getNodeName(), ex);
            }
          }
        }
      }
    }

    return nameValueAttributeMap;
  }