Coverage report

  %line %branch
net.sf.tlc.core.impl.JarInspector
82% 
100% 

 1  
 /*
 2  
  * Created on May 26, 2005
 3  
  *
 4  
  * Used by DefaultFinder to inspect inside JARs to find potential targets.
 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  
  * Used by DefaultFinder to inspect inside JARs to find potential targets.
 20  
  * 
 21  
  * @author aisrael
 22  
  */
 23  
 public final class JarInspector {
 24  
     
 25  
     /**
 26  
      * JarInspector instances should NOT be constructed in standard programming.
 27  
      */
 28  0
     private JarInspector() {
 29  
         // noop
 30  0
     }
 31  
 
 32  
     /**
 33  
      * @param jarFile
 34  
      *            File
 35  
      * @return Target[]
 36  
      * @throws IOException on IOException
 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  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.