/**
  * Reads all of the files in the given directory and adds them as children of the directory tree
  * node. Requires that the passed node represents a directory.
  */
 private void readDirectory(Node parentNode, File parentDir) {
   File[] children = parentDir.listFiles();
   if (children == null) return;
   if (verbose) {
     System.out.print(".");
     System.out.flush();
   }
   for (int i = 0; i < children.length; i++) {
     File child = children[i];
     children[i] = null;
     boolean isDir = child.isDirectory();
     boolean mustSkip = false;
     if (isDir) {
       for (Iterator iter = subdirsToIgnore.iterator(); iter.hasNext(); ) {
         if (child.getName().equals((String) iter.next())) {
           mustSkip = true;
           break;
         }
       }
     }
     if (!mustSkip) {
       Node childNode = new Node(child);
       parentNode.addChild(childNode);
       if (isDir) {
         readDirectory(childNode, child);
       }
     }
   }
 }
Esempio n. 2
0
 public Node<ResourceName> queryMDSAsTree(PackageName packageName) {
   Node<ResourceName> tree = new Node<ResourceName>(packageName);
   List<ResourceName> resourceNames = queryMDS(packageName);
   for (ResourceName r : resourceNames) {
     Node<ResourceName> newNode = new Node<ResourceName>(r);
     if (r instanceof PackageName) {
       newNode.addChildrenOf(queryMDSAsTree((PackageName) r));
     }
     tree.addChild(newNode);
   }
   return tree;
 }
Esempio n. 3
0
    boolean insert(Node p, List<Node> Qi, int level) {
      Node parent = null;
      List<Node> nQi = new ArrayList<Node>();
      for (Node q : Qi) {
        if (dist(p, q) <= layerSize[level]) {
          nQi.add(q);
          parent = q;
        }
      }

      if (parent == null) // separation holds
      return true;

      for (Node q : Qi)
        for (Node ch : q.getChildren(level)) if (dist(p, ch) <= layerSize[level]) nQi.add(ch);

      if (insert(p, nQi, level + 1)) parent.addChild(p, level);

      return false;
    }