org.eclipse.osgi.baseadaptor.bundlefile
Class BundleFile

java.lang.Object
  extended by org.eclipse.osgi.baseadaptor.bundlefile.BundleFile
Direct Known Subclasses:
DirBundleFile, NestedDirBundleFile, ZipBundleFile

public abstract class BundleFile
extends java.lang.Object

The BundleFile API is used by Adaptors to read resources out of an installed Bundle in the Framework.

Clients may extend this class.

Since:
3.2

Field Summary
protected  java.io.File basefile
          The File object for this BundleFile.
protected static java.lang.String PROP_SETPERMS_CMD
           
 
Constructor Summary
BundleFile()
          Default constructor
BundleFile(java.io.File basefile)
          BundleFile constructor
 
Method Summary
abstract  void close()
          Closes the BundleFile.
abstract  boolean containsDir(java.lang.String dir)
          Determines if any BundleEntries exist in the given directory path.
 java.io.File getBaseFile()
          Returns the base file for this BundleFile
abstract  BundleEntry getEntry(java.lang.String path)
          Locates a file name in this bundle and returns a BundleEntry object
abstract  java.util.Enumeration getEntryPaths(java.lang.String path)
          Allows to access the entries of the bundle.
abstract  java.io.File getFile(java.lang.String path, boolean nativeCode)
          Returns a File for the bundle entry specified by the path.
 java.net.URL getResourceURL(java.lang.String path, long hostBundleID)
          Returns a URL to access the contents of the entry specified by the path
 java.net.URL getResourceURL(java.lang.String path, long hostBundleID, int index)
          Returns a URL to access the contents of the entry specified by the path
abstract  void open()
          Opens the BundleFiles.
static void setPermissions(java.io.File file)
          Attempts to set the permissions of the file in a system dependant way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_SETPERMS_CMD

protected static final java.lang.String PROP_SETPERMS_CMD
See Also:
Constant Field Values

basefile

protected java.io.File basefile
The File object for this BundleFile.

Constructor Detail

BundleFile

public BundleFile()
Default constructor


BundleFile

public BundleFile(java.io.File basefile)
BundleFile constructor

Parameters:
basefile - The File object where this BundleFile is persistently stored.
Method Detail

getFile

public abstract java.io.File getFile(java.lang.String path,
                                     boolean nativeCode)
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.

Parameters:
path - 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.

getEntry

public abstract BundleEntry getEntry(java.lang.String path)
Locates a file name in this bundle and returns a BundleEntry object

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 abstract java.util.Enumeration getEntryPaths(java.lang.String path)
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.

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 abstract void close()
                    throws java.io.IOException
Closes the BundleFile.

Throws:
java.io.IOException - if any error occurs.

open

public abstract void open()
                   throws java.io.IOException
Opens the BundleFiles.

Throws:
java.io.IOException - if any error occurs.

containsDir

public abstract boolean containsDir(java.lang.String dir)
Determines if any BundleEntries exist in the given directory path.

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

getResourceURL

public java.net.URL getResourceURL(java.lang.String path,
                                   long hostBundleID)
Returns a URL to access the contents of the entry specified by the path

Parameters:
path - the path to the resource
hostBundleID - the host bundle ID
Returns:
a URL to access the contents of the entry specified by the path

getResourceURL

public java.net.URL getResourceURL(java.lang.String path,
                                   long hostBundleID,
                                   int index)
Returns a URL to access the contents of the entry specified by the path

Parameters:
path - the path to the resource
hostBundleID - the host bundle ID
index - the resource index
Returns:
a URL to access the contents of the entry specified by the path

getBaseFile

public java.io.File getBaseFile()
Returns the base file for this BundleFile

Returns:
the base file for this BundleFile

setPermissions

public static void setPermissions(java.io.File file)
Attempts to set the permissions of the file in a system dependant way.

Parameters:
file - the file to set the permissions on