com.caucho.vfs
Class Jar

java.lang.Object
  extended by com.caucho.vfs.Jar
All Implemented Interfaces:
CacheListener

public class Jar
extends java.lang.Object
implements CacheListener

Jar is a cache around a jar file to avoid scanning through the whole file on each request.

When the Jar is created, it scans the file and builds a directory of the Jar entries.


Nested Class Summary
 class Jar.ZipStreamImpl
          StreamImpl to read from a ZIP file.
 
Method Summary
 boolean canRead(java.lang.String path)
          Readable if the jar is readable and the path refers to a file.
 boolean canWrite(java.lang.String path)
          Can't write to jars.
 void clearCache()
          Clears any cached JarFile.
static void clearJarCache()
          Clears all the cached files in the jar.
 void close()
           
 void closeZipFile(java.util.zip.ZipFile zipFile)
           
static PersistentDependency createDepend(Path backing)
          Return a Jar for the path.
static PersistentDependency createDepend(Path backing, long digest)
          Return a Jar for the path.
 boolean equals(java.lang.Object o)
           
 boolean exists(java.lang.String path)
          Returns true if the entry exists in the jar.
 java.security.cert.Certificate[] getCertificates(java.lang.String path)
          Returns any certificates.
 int getChangeSequence()
           
 PersistentDependency getDepend()
          Returns the dependency.
 long getLastModified(java.lang.String path)
          Returns the last-modified time of the entry in the jar file.
 long getLength(java.lang.String path)
          Returns the length of the entry in the jar file.
 java.util.jar.Manifest getManifest()
          Returns true if the entry is a file in the jar.
 java.util.zip.ZipEntry getZipEntry(java.lang.String path)
           
 java.util.zip.ZipFile getZipFile()
          Returns the Java ZipFile for this Jar.
 boolean isDirectory(java.lang.String path)
          Returns true if the entry is a directory in the jar.
 boolean isFile(java.lang.String path)
          Returns true if the entry is a file in the jar.
 java.lang.String[] list(java.lang.String path)
          Lists all the files in this directory.
 Jar.ZipStreamImpl openReadImpl(Path path)
          Opens a stream to an entry in the jar.
 Jar.ZipStreamImpl openReadImpl(java.lang.String pathName)
           
 void removeEvent()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createDepend

public static PersistentDependency createDepend(Path backing)
Return a Jar for the path. If the backing already exists, return the old jar.


createDepend

public static PersistentDependency createDepend(Path backing,
                                                long digest)
Return a Jar for the path. If the backing already exists, return the old jar.


getDepend

public PersistentDependency getDepend()
Returns the dependency.


getChangeSequence

public int getChangeSequence()

getManifest

public java.util.jar.Manifest getManifest()
                                   throws java.io.IOException
Returns true if the entry is a file in the jar.

Parameters:
path - the path name inside the jar.
Throws:
java.io.IOException

getCertificates

public java.security.cert.Certificate[] getCertificates(java.lang.String path)
Returns any certificates.


exists

public boolean exists(java.lang.String path)
Returns true if the entry exists in the jar.

Parameters:
path - the path name inside the jar.

isDirectory

public boolean isDirectory(java.lang.String path)
Returns true if the entry is a directory in the jar.

Parameters:
path - the path name inside the jar.

isFile

public boolean isFile(java.lang.String path)
Returns true if the entry is a file in the jar.

Parameters:
path - the path name inside the jar.

getLastModified

public long getLastModified(java.lang.String path)
Returns the last-modified time of the entry in the jar file.

Parameters:
path - full path to the jar entry
Returns:
the length of the entry

getLength

public long getLength(java.lang.String path)
Returns the length of the entry in the jar file.

Parameters:
path - full path to the jar entry
Returns:
the length of the entry

canRead

public boolean canRead(java.lang.String path)
Readable if the jar is readable and the path refers to a file.


canWrite

public boolean canWrite(java.lang.String path)
Can't write to jars.


list

public java.lang.String[] list(java.lang.String path)
                        throws java.io.IOException
Lists all the files in this directory.

Throws:
java.io.IOException

openReadImpl

public Jar.ZipStreamImpl openReadImpl(Path path)
                               throws java.io.IOException
Opens a stream to an entry in the jar.

Parameters:
path - relative path into the jar.
Throws:
java.io.IOException

openReadImpl

public Jar.ZipStreamImpl openReadImpl(java.lang.String pathName)
                               throws java.io.IOException
Throws:
java.io.IOException

clearCache

public void clearCache()
Clears any cached JarFile.


getZipEntry

public java.util.zip.ZipEntry getZipEntry(java.lang.String path)
                                   throws java.io.IOException
Throws:
java.io.IOException

getZipFile

public java.util.zip.ZipFile getZipFile()
                                 throws java.io.IOException
Returns the Java ZipFile for this Jar. Accessing the entries with the ZipFile is faster than scanning through them. getJarFile is not thread safe.

Throws:
java.io.IOException

closeZipFile

public void closeZipFile(java.util.zip.ZipFile zipFile)

close

public void close()

removeEvent

public void removeEvent()
Specified by:
removeEvent in interface CacheListener

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

clearJarCache

public static void clearJarCache()
Clears all the cached files in the jar. Needed to avoid some windows NT issues.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object