@Override public <T> Path.Entry<T> get(ID eid, Content.Type<T> ct) throws IOException { updateContents(); ID tid = id.append(eid.get(0)); int idx = binarySearch(contents, nentries, tid); if (idx >= 0) { // At this point, we've found a matching index for the given ID. // However, there maybe multiple matching IDs with different // content types. Therefore, we need to check them all to see if // they match the requested entry. Path.Item item = contents[idx]; do { if (item instanceof Entry && eid.size() == 1) { // In this case, we're looking for and have found an exact // item. Entry entry = (Entry) item; if (entry.contentType() == ct) { return entry; } } else if (item instanceof Path.Folder && eid.size() > 1) { // In this case, the ID is indicates the item is not // contained in this folder. Path.Folder folder = (Path.Folder) item; return folder.get(eid.subpath(1, eid.size()), ct); } } while (++idx < nentries && (item = contents[idx]).id().equals(tid)); } // no dice return null; }
protected Path.Folder getFolder(String name) throws IOException { updateContents(); ID tid = id.append(name); int idx = binarySearch(contents, nentries, tid); if (idx >= 0) { // At this point, we've found a matching index for the given ID. // However, there maybe multiple matching IDs with different // content types. Therefore, we need to check them all to see if // they match the requested entry. Path.Item item = contents[idx]; do { if (item instanceof Path.Folder) { // In this case, the ID is indicates the item is not // contained in this folder. return (Path.Folder) item; } } while (++idx < nentries && (item = contents[idx]).id().equals(tid)); } // no dice return null; }