org.eclipse.osgi.baseadaptor.bundlefile
Class BundleFile

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

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

Field Detail

PROP_SETPERMS_CMD

protected static final String PROP_SETPERMS_CMD
See Also:
Constant Field Values

basefile

protected File basefile
The File object for this BundleFile.

Constructor Detail

BundleFile

public BundleFile()
Default constructor


BundleFile

public BundleFile(File basefile)
BundleFile constructor

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

getFile

public abstract File getFile(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(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 Enumeration<String> getEntryPaths(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 IOException
Closes the BundleFile.

Throws:
IOException - if any error occurs.

open

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

Throws:
IOException - if any error occurs.

containsDir

public abstract boolean containsDir(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 URL getResourceURL(String path,
                          long hostBundleID)
Deprecated. use getResourceURL(String, BaseData, int)

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 URL getResourceURL(String path,
                          long hostBundleID,
                          int index)
Deprecated. use getResourceURL(String, BaseData, int)

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

getResourceURL

public URL getResourceURL(String path,
                          BaseData hostData,
                          int index)
Returns a URL to access the contents of the entry specified by the path

Parameters:
path - the path to the resource
hostData - the host BaseData
index - the resource index
Returns:
a URL to access the contents of the entry specified by the path

getBaseFile

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

Returns:
the base file for this BundleFile

setPermissions

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

Parameters:
file - the file to set the permissions on

toString

public String toString()
Overrides:
toString in class Object

fixTrailingSlash

public static String fixTrailingSlash(String path,
                                      BundleEntry entry)


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.