| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
package net.sf.tlc.core.impl; |
| 7 |
|
|
| 8 |
|
import java.io.File; |
| 9 |
|
import java.io.IOException; |
| 10 |
|
import java.util.ArrayList; |
| 11 |
|
import java.util.Enumeration; |
| 12 |
|
import java.util.zip.ZipEntry; |
| 13 |
|
import java.util.zip.ZipFile; |
| 14 |
|
|
| 15 |
|
import net.sf.tlc.model.Target; |
| 16 |
|
import net.sf.tlc.util.ClassPathUtils; |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
public final class JarInspector { |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
0 |
private JarInspector() { |
| 29 |
|
|
| 30 |
0 |
} |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public static Target[] listTargets(final File jarFile) throws IOException { |
| 39 |
20 |
final ArrayList targets = new ArrayList(); |
| 40 |
20 |
final ZipFile zip = new ZipFile(jarFile); |
| 41 |
20 |
final Enumeration entries = zip.entries(); |
| 42 |
190 |
while (entries.hasMoreElements()) { |
| 43 |
160 |
final ZipEntry entry = (ZipEntry) entries.nextElement(); |
| 44 |
160 |
if (!entry.isDirectory() && entry.getName().endsWith(".class")) { |
| 45 |
80 |
final String className = ClassPathUtils.toClassName(entry.getName()); |
| 46 |
80 |
targets.add(new Target(Target.TARGET_IS_JAR, jarFile.getAbsolutePath(), className)); |
| 47 |
|
} |
| 48 |
|
} |
| 49 |
20 |
return (Target[]) targets.toArray(new Target[0]); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
} |