Enumeration en = zipfile.entries();
HashMap newRepositories = new HashMap();
HashMap newResources = new HashMap();
while (en.hasMoreElements()) {
ZipEntry entry = (ZipEntry) en.nextElement();
String eName = entry.getName();
if (!eName.regionMatches(0, entryPath, 0, entryPath.length())) {
// names don't match - not a child of ours
continue;
}
String[] entrypath = StringUtils.split(eName, "/");
if (depth > 0 && !shortName.equals(entrypath[depth-1])) {
// catch case where our name is Foo and other's is FooBar
continue;
}
// create new repositories and resources for all entries with a
// path depth of this.depth + 1
if (entrypath.length == depth + 1 && !entry.isDirectory()) {
// create a new child resource
ZipResource resource = new ZipResource(entry.getName(), this);
newResources.put(resource.getShortName(), resource);
} else if (entrypath.length > depth) {
// create a new child repository
if (!newRepositories.containsKey(entrypath[depth])) {
ZipEntry child = composeChildEntry(entrypath[depth]);
ZipRepository rep = new ZipRepository(file, this, child);
newRepositories.put(entrypath[depth], rep);
}
}
}