Ejemplo n.º 1
0
  public static ArrayList<String> getHitEidsFromHits(String xmlResultInString) {
    ArrayList<String> _hitEids = new ArrayList<String>();
    Document doc = XMLParser.parse(xmlResultInString);
    NodeList hits = doc.getElementsByTagName("doc");

    for (int i = 0; i < hits.getLength(); i++) {
      Node hit = hits.item(i);

      NodeList hitDocChildNodes = hit.getChildNodes();

      String entity_id = "";

      for (int j = 0; j < hitDocChildNodes.getLength(); j++) {
        Node hitDocChildNode = hitDocChildNodes.item(j);

        NamedNodeMap attrs = hitDocChildNode.getAttributes();
        Node _attributeNode = null;
        _attributeNode = attrs.getNamedItem("name");

        if (_attributeNode != null) {
          if (_attributeNode.getNodeValue().equals("entity_id")) {
            entity_id = hitDocChildNode.getFirstChild().getNodeValue();
          }
        }
      }

      _hitEids.add(entity_id);
    }

    return _hitEids;
  }
Ejemplo n.º 2
0
  public static ArrayList<String> getUsedFqnFromHits(String xmlResultInString) {
    ArrayList<String> usedFqns = new ArrayList<String>();

    Document doc = XMLParser.parse(xmlResultInString);
    NodeList _arrs = doc.getElementsByTagName("arr");

    for (int i = 0; i < _arrs.getLength(); i++) {
      Node _arr = _arrs.item(i);
      NamedNodeMap _nnm = _arr.getAttributes();
      if (_nnm != null) {
        Node _nameNode = _nnm.getNamedItem("name");
        if (_nameNode != null) {
          String _nodeType = _nameNode.getNodeValue();
          if (_nodeType.equals("lib_use_fqn_full")
              || _nodeType.equals("jdk_use_fqn_full")
              || _nodeType.equals("local_use_fqn_full")) {
            NodeList _fqns = _arr.getChildNodes();
            for (int j = 0; j < _fqns.getLength(); j++) {
              Node _fqn = _fqns.item(j);
              if (_fqn.getNodeName().equals("str")) {
                String _usedFqn = _fqn.getFirstChild().getNodeValue();
                usedFqns.add(_usedFqn);
              }
            }
          }
        }
      }
    }
    return usedFqns;
  }
Ejemplo n.º 3
0
  public static List<HitFqnEntityId> getFqnEntityIdFromHits(String xmlResultInString) {

    List<HitFqnEntityId> hitsInfo = new LinkedList<HitFqnEntityId>();

    Node responseNode = getResponseNode(xmlResultInString);
    NodeList hits = responseNode.getChildNodes();

    for (int i = 0; i < hits.getLength(); i++) {
      String fqn = "";
      String entity_id = "";

      Node hit = hits.item(i);
      if (!hit.getNodeName().equals("doc")) continue;

      NodeList hitDocChildNodes = hit.getChildNodes();

      for (int j = 0; j < hitDocChildNodes.getLength(); j++) {
        Node hitDocChildNode = hitDocChildNodes.item(j);

        NamedNodeMap attrs = hitDocChildNode.getAttributes();
        Node _attributeNode = null;
        _attributeNode = attrs.getNamedItem("name");

        if (_attributeNode != null) {
          if (_attributeNode.getNodeValue().equals("entity_id")) {
            entity_id = hitDocChildNode.getFirstChild().getNodeValue();
          } else if (_attributeNode.getNodeValue().equals("fqn_full")) {
            fqn = hitDocChildNode.getFirstChild().getNodeValue();
          }
        }
      }

      hitsInfo.add(new HitFqnEntityId(fqn, entity_id));
    }
    return hitsInfo;
  }
Ejemplo n.º 4
0
  public static List<HitFqnEntityId> getUsedApisFromFacetedHits(
      String xmlResultInString, EntityCategory c) {

    //		if (c.equals(EntityCategory.LOCAL))
    //			throw new IllegalArgumentException("only jdk or lib");

    List<HitFqnEntityId> apis = new LinkedList<HitFqnEntityId>();

    Document doc = XMLParser.parse(xmlResultInString);
    NodeList apisNodes = doc.getElementsByTagName("lst");

    String nodeName;

    if (c.equals(EntityCategory.JDK)) nodeName = "jdk_use_fqn_full";
    else if (c.equals(EntityCategory.LIB)) nodeName = "lib_use_fqn_full";
    else return apis;

    for (int i = 0; i < apisNodes.getLength(); i++) {
      Node apiNode = apisNodes.item(i);
      NamedNodeMap attrs = apiNode.getAttributes();
      Node _attributeNode = null;
      _attributeNode = attrs.getNamedItem("name");

      if (_attributeNode != null) {
        if (_attributeNode.getNodeValue().equals(nodeName)) {
          // iterate through int nodes
          NodeList fqnNodes = apiNode.getChildNodes();

          for (int j = 0; j < fqnNodes.getLength(); j++) {
            Node fqnNode = fqnNodes.item(j);
            if (fqnNode.getNodeName().equals("int")) {
              String fqn = getAttributeValue(fqnNode, "name");
              if (fqn != null) {
                String count = fqnNode.getFirstChild().getNodeValue();

                HitFqnEntityId _apiFqn = new HitFqnEntityId(fqn, "-1", count);
                apis.add(_apiFqn);
              }
            }
          }
        }
      }
    }

    return apis;
  }