org.eclipse.osgi.baseadaptor.bundlefile
Class ZipBundleFile

java.lang.Object
  extended by org.eclipse.osgi.baseadaptor.bundlefile.BundleFile
      extended by org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile

public class ZipBundleFile
extends BundleFile

A BundleFile that uses a ZipFile as it base file.

Since:
3.2

Field Summary
protected  BaseData bundledata
          The bundle data
protected  boolean closed
          The closed flag
protected static MRUBundleFileList mruList
           
protected  java.util.zip.ZipFile zipFile
          The zip file
 
Fields inherited from class org.eclipse.osgi.baseadaptor.bundlefile.BundleFile
basefile, PROP_SETPERMS_CMD
 
Constructor Summary
ZipBundleFile(java.io.File basefile, BaseData bundledata)
          Constructs a ZipBundle File
 
Method Summary
protected  java.util.zip.ZipFile basicOpen()
          Opens the ZipFile for this bundle file
protected  boolean checkedOpen()
          Checks if the zip file is open
 void close()
          Closes the BundleFile.
 boolean containsDir(java.lang.String dir)
          Determines if any BundleEntries exist in the given directory path.
protected  java.io.File extractDirectory(java.lang.String dirName)
          Extracts a directory and all sub content to disk
 BundleEntry getEntry(java.lang.String path)
          Locates a file name in this bundle and returns a BundleEntry object
 java.util.Enumeration getEntryPaths(java.lang.String path)
          Allows to access the entries of the bundle.
protected  java.io.File getExtractFile(java.lang.String entryName)
           
 java.io.File getFile(java.lang.String entry, boolean nativeCode)
          Returns a File for the bundle entry specified by the path.
protected  java.util.zip.ZipEntry getZipEntry(java.lang.String path)
          Returns a ZipEntry for the bundle file.
protected  java.util.zip.ZipFile getZipFile()
          Returns an open ZipFile for this bundle file.
 void open()
          Opens the BundleFiles.
static void shutdown()
          Shutsdown the bundle file closer thread for zip bundle files
 
Methods inherited from class org.eclipse.osgi.baseadaptor.bundlefile.BundleFile
getBaseFile, getResourceURL, getResourceURL, getResourceURL, setPermissions, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mruList

protected static MRUBundleFileList mruList

bundledata

protected BaseData bundledata
The bundle data


zipFile

protected java.util.zip.ZipFile zipFile
The zip file


closed

protected boolean closed
The closed flag

Constructor Detail

ZipBundleFile

public ZipBundleFile(java.io.File basefile,
                     BaseData bundledata)
              throws java.io.IOException
Constructs a ZipBundle File

Parameters:
basefile - the base file
bundledata - the bundle data
Throws:
java.io.IOException
Method Detail

checkedOpen

protected boolean checkedOpen()
Checks if the zip file is open

Returns:
true if the zip file is open

basicOpen

protected java.util.zip.ZipFile basicOpen()
                                   throws java.io.IOException
Opens the ZipFile for this bundle file

Returns:
an open ZipFile for this bundle file
Throws:
java.io.IOException

getZipFile

protected java.util.zip.ZipFile getZipFile()
                                    throws java.io.IOException
Returns an open ZipFile for this bundle file. If an open ZipFile does not exist then a new one is created and returned.

Returns:
an open ZipFile for this bundle
Throws:
java.io.IOException

getZipEntry

protected java.util.zip.ZipEntry getZipEntry(java.lang.String path)
Returns a ZipEntry for the bundle file. Must be called while synchronizing on this object. This method does not ensure that the ZipFile is opened. Callers may need to call getZipfile() prior to calling this method.

Parameters:
path - the path to an entry
Returns:
a ZipEntry or null if the entry does not exist

extractDirectory

protected java.io.File extractDirectory(java.lang.String dirName)
Extracts a directory and all sub content to disk

Parameters:
dirName - the directory name to extract
Returns:
the File used to extract the content to. A value of null is returned if the directory to extract does not exist or if content extraction is not supported.

getExtractFile

protected java.io.File getExtractFile(java.lang.String entryName)

getFile

public java.io.File getFile(java.lang.String entry,
                            boolean nativeCode)
Description copied from class: BundleFile
Returns a File for the bundle entry specified by the path. If required the content of the bundle entry is extracted into a file on the file system.

Specified by:
getFile in class BundleFile
Parameters:
entry - The path to the entry to locate a File for.
nativeCode - true if the path is native code.
Returns:
A File object to access the contents of the bundle entry.

containsDir

public boolean containsDir(java.lang.String dir)
Description copied from class: BundleFile
Determines if any BundleEntries exist in the given directory path.

Specified by:
containsDir in class BundleFile
Parameters:
dir - The directory path to check existence of.
Returns:
true if the BundleFile contains entries under the given directory path; false otherwise.

getEntry

public BundleEntry getEntry(java.lang.String path)
Description copied from class: BundleFile
Locates a file name in this bundle and returns a BundleEntry object

Specified by:
getEntry in class BundleFile
Parameters:
path - path of the entry to locate in the bundle
Returns:
BundleEntry object or null if the file name does not exist in the bundle

getEntryPaths

public java.util.Enumeration getEntryPaths(java.lang.String path)
Description copied from class: BundleFile
Allows to access the entries of the bundle. Since the bundle content is usually a jar, this allows to access the jar contents. GetEntryPaths allows to enumerate the content of "path". If path is a directory, it is equivalent to listing the directory contents. The returned names are either files or directories themselves. If a returned name is a directory, it finishes with a slash. If a returned name is a file, it does not finish with a slash.

Specified by:
getEntryPaths in class BundleFile
Parameters:
path - path of the entry to locate in the bundle
Returns:
an Enumeration of Strings that indicate the paths found or null if the path does not exist.

close

public void close()
           throws java.io.IOException
Description copied from class: BundleFile
Closes the BundleFile.

Specified by:
close in class BundleFile
Throws:
java.io.IOException - if any error occurs.

open

public void open()
          throws java.io.IOException
Description copied from class: BundleFile
Opens the BundleFiles.

Specified by:
open in class BundleFile
Throws:
java.io.IOException - if any error occurs.

shutdown

public static void shutdown()
Shutsdown the bundle file closer thread for zip bundle files