Commit 55aeaefc authored by Jesper Öqvist's avatar Jesper Öqvist
Browse files

Refactored ZipFilePart - added constructor

parent ead24fbb
......@@ -458,16 +458,43 @@ aspect ClassPath {
}
}
// load files in a zip file
/**
* Loads class files from a zip file (Jar file)
*/
class ZipFilePart extends PathPart {
private HashSet set = new HashSet();
private ZipFile file;
private String zipPath;
public boolean hasPackage(String name) {
return set.contains(name);
}
public ZipFilePart(ZipFile file, String path) {
zipPath = path;
this.file = file;
// process all entries in the zip file
for (Enumeration e = file.entries() ; e.hasMoreElements() ;) {
ZipEntry entry = (ZipEntry)e.nextElement();
String pathName = new File(entry.getName()).getParent();
if(pathName != null)
pathName = pathName.replace(File.separatorChar, '.');
if(!set.contains(pathName)) {
int pos = 0;
while(pathName != null && -1 != (pos = pathName.indexOf('.', pos + 1))) {
String n = pathName.substring(0, pos);
if(!set.contains(n)) {
set.add(n);
}
}
set.add(pathName);
}
set.add(entry.getName());
}
}
public ZipFilePart(ZipFile file) {
zipPath = file.getName();
this.file = file;
// process all entries in the zip file
for (Enumeration e = file.entries() ; e.hasMoreElements() ;) {
......@@ -497,7 +524,7 @@ aspect ClassPath {
if(zipEntry != null && !zipEntry.isDirectory()) {
is = file.getInputStream(zipEntry);
age = zipEntry.getTime();
pathName = file.getName();
pathName = zipPath;
relativeName = name + fileSuffix();
fullName = canonicalName;
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment