Beispiel #1
0
  @Override
  public <T> void getAll(Content.Filter<T> filter, Set<Path.ID> entries) throws IOException {
    updateContents();

    // It would be nice to further optimise this loop. The key issue is that,
    // at some point, we might know the filter could never match. In which
    // case, we want to stop the recursion early, rather than exploring a
    // potentially largel subtree.

    for (int i = 0; i != nentries; ++i) {
      Path.Item item = contents[i];
      if (item instanceof Entry) {
        Entry entry = (Entry) item;
        if (filter.matches(entry.id(), entry.contentType())) {
          entries.add(entry.id());
        }
      } else if (item instanceof Path.Folder && filter.matchesSubpath(item.id())) {
        Path.Folder folder = (Path.Folder) item;
        folder.getAll(filter, entries);
      }
    }
  }
Beispiel #2
0
  @Override
  public List<Entry<?>> getAll() throws IOException {
    ArrayList entries = new ArrayList();
    updateContents();

    // It would be nice to further optimise this loop. Basically, to avoid
    // creating so many ArrayList objects. However, it's tricky to get right
    // given Java's generic type system.

    for (int i = 0; i != nentries; ++i) {
      Path.Item item = contents[i];
      if (item instanceof Entry) {
        Entry entry = (Entry) item;
        entries.add(entry);
      } else if (item instanceof Path.Folder) {
        Path.Folder folder = (Path.Folder) item;
        entries.addAll(folder.getAll());
      }
    }

    return entries;
  }