public static List<FolderIndex> getIndexList(Index node) {
   List<FolderIndex> digest = new ArrayList<FolderIndex>();
   if (node.isFolder()) {
     // add self
     digest.add((FolderIndex) node);
     // add children
     for (Index child : ((FolderIndex) node).getChildren()) {
       if (child.isFolder()) digest.addAll(getIndexList(child));
     }
   }
   return digest;
 }
Exemplo n.º 2
0
  /**
   * Return sif the node is shared or has any children that are shared.
   *
   * @return if the node is shared or has a shared sub-section
   */
  public boolean isSharedOrHasSharedChildren() {
    if (isShared()) {
      // this is a shared file or a shared (sub) folder
      return true;
    }

    if (this instanceof FileIndex) {
      // is not shared and is of type 'file'
      return false;
    } else {
      // is of type 'folder', check all subfolders
      List<Index> children = getIndexList(this);
      for (Index child : children) {
        if (child.isFolder()) {
          FolderIndex subfolder = (FolderIndex) child;
          if (subfolder.getSharedFlag()) {
            return true;
          }
        }
      }
    }

    // no case above matches
    return false;
  }
Exemplo n.º 3
0
  /**
   * Walks recursively through the file tree and returns a preorder list
   *
   * @param node The root node from which the digest is started.
   * @return The digest in preorder
   */
  public static List<Index> getIndexList(Index node) {
    List<Index> digest = new ArrayList<Index>();

    // add self
    digest.add(node);

    // add children
    if (node.isFolder()) {
      FolderIndex folder = (FolderIndex) node;
      for (Index child : folder.getChildren()) {
        digest.addAll(getIndexList(child));
      }
    }

    return digest;
  }