Class BundleFile
java.lang.Object
org.eclipse.osgi.storage.bundlefile.BundleFile
- Direct Known Subclasses:
BundleFileWrapper
,CloseableBundleFile
,DirBundleFile
,NestedDirBundleFile
,SystemBundleFile
The BundleFile API is used by Adaptors to read resources out of an installed
Bundle in the Framework.
Clients wishing to modify or extend the functionality of this class at
runtime should extend the associated decorator
instead.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Closes the BundleFile.abstract boolean
containsDir
(String dir) Determines if any BundleEntries exist in the given directory path.protected URL
createResourceURL
(BundleEntry bundleEntry, Module hostModule, int index, String path) Creates a URL to access the content of the specified entrystatic URL
createURL
(String protocol, long bundleId, ModuleContainer container, BundleEntry entry, int index, String path, URLStreamHandler handler) static String
fixTrailingSlash
(String path, BundleEntry entry) Returns the base file for this BundleFileabstract BundleEntry
Locates a file name in this bundle and returns a BundleEntry objectgetEntryPaths
(String path) abstract Enumeration<String>
getEntryPaths
(String path, boolean recurse) Allows to access the entries of the bundle.abstract File
Returns a File for the bundle entry specified by the path.getResourceURL
(String path, Module hostModule, int index) Returns a URL to access the contents of the entry specified by the path.abstract void
open()
Opens the BundleFiles.toString()
-
Field Details
-
basefile
The File object for this BundleFile.
-
-
Constructor Details
-
BundleFile
BundleFile constructor- Parameters:
basefile
- The File object where this BundleFile is persistently stored.
-
-
Method Details
-
getFile
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
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
- 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.
-
getEntryPaths
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 bundlerecurse
- - Iftrue
, provide entries for the files and directories within the directory denoted bypath
plus all sub-directories and files; otherwise, provide only the entries within the immediate directory.- Returns:
- an Enumeration of Strings that indicate the paths found or null if the path does not exist.
-
close
Closes the BundleFile.- Throws:
IOException
- if any error occurs.
-
open
Opens the BundleFiles.- Throws:
IOException
- if any error occurs.
-
containsDir
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
Returns a URL to access the contents of the entry specified by the path. This method first callsgetEntry(String)
to locate the entry at the specified path. If no entry is foundnull
is returned; otherwisecreateResourceURL(BundleEntry, Module, int, String)
is called in order to create the URL. Subclasses should not override this method. Instead the methodsgetEntry(String)
and/orcreateResourceURL(BundleEntry, Module, int, String)
may be overriden to augment the behavior.- Parameters:
path
- the path to the resourcehostModule
- the host moduleindex
- the resource index- Returns:
- a URL to access the contents of the entry specified by the path
-
createResourceURL
Creates a URL to access the content of the specified entry- Parameters:
bundleEntry
- the bundle entryhostModule
- the host moduleindex
- the resource index- Returns:
- a URL to access the contents of the specified entry
-
getBaseFile
Returns the base file for this BundleFile- Returns:
- the base file for this BundleFile
-
toString
-
createURL
public static URL createURL(String protocol, long bundleId, ModuleContainer container, BundleEntry entry, int index, String path, URLStreamHandler handler) -
fixTrailingSlash
-