FileDocCategorySizeDatePackage
JarFileArchive.javaAPI DocGlassfish v2 API4299Thu Jul 26 10:51:00 BST 2007oracle.toplink.essentials.ejb.cmp3.persistence

JarFileArchive

public class JarFileArchive extends Object implements Archive
This is an implementation of {@link Archive} when container returns a file: url that refers to a jar file. e.g. file:/tmp/a_ear/lib/pu.jar
author
Sanjeeb.Sahoo@Sun.COM

Fields Summary
private JarFile
jarFile
private URL
rootURL
private Logger
logger
Constructors Summary
public JarFileArchive(JarFile jarFile)

        this(jarFile, Logger.global);
    
public JarFileArchive(JarFile jarFile, Logger logger)

        logger.entering("JarFileArchive", "JarFileArchive", // NOI18N
                new Object[]{jarFile});
        this.logger = logger;
        this.jarFile = jarFile;
        rootURL = new File(jarFile.getName()).toURI().toURL();
        logger.logp(Level.FINER, "JarFileArchive", "JarFileArchive", // NOI18N
                "rootURL = {0}", rootURL); // NOI18N
    
Methods Summary
public java.util.IteratorgetEntries()

        Enumeration<JarEntry> jarEntries = jarFile.entries();
        ArrayList<String> result = new ArrayList<String>();
        while (jarEntries.hasMoreElements()) {
            final JarEntry jarEntry = jarEntries.nextElement();
            if(!jarEntry.isDirectory()) { // exclude directory entries
                result.add(jarEntry.getName());
            }
        }
        return result.iterator();
    
public java.io.InputStreamgetEntry(java.lang.String entryPath)

        InputStream is = null;
        final ZipEntry entry = jarFile.getEntry(entryPath);
        if (entry != null) {
            is = jarFile.getInputStream(entry);
        }
        return is;
    
public java.net.URLgetEntryAsURL(java.lang.String entryPath)

        return jarFile.getEntry(entryPath)!= null ?
                new URL("jar:"+rootURL+"!/"+entryPath) : null; // NOI18N
    
public java.net.URLgetRootURL()

        return rootURL;