org.jboss.osgi.vfs
Interface VirtualFile


public interface VirtualFile

A basic abstraction of a VirtualFile used by the OSGi layer. This abstraction should be removed once we settle on a single jboss-vfs version.

Since:
02-Mar-2010
Author:
thomas.diesler@jboss.com

Method Summary
 void close()
          Close the file resources (stream, etc.)
 Enumeration<URL> findEntries(String path, String pattern, boolean recurse)
          Returns entries in this bundle and its attached fragments.
 VirtualFile getChild(String path)
          Get a child
 List<VirtualFile> getChildren()
          Get the children
 List<VirtualFile> getChildrenRecursively()
          Get all children recursively
 Enumeration<String> getEntryPaths(String path)
          Returns an Enumeration of all the paths (String objects) to entries within this bundle whose longest sub-path matches the specified path.
 String getName()
          Get the simple VF name (X.java)
 VirtualFile getParent()
          Get the parent
 String getPathName()
          Get the VFS relative path name (org/jboss/X.java)
 URL getStreamURL()
          Get the URL used for streaming.
 boolean isDirectory()
          Whether it is a directory in the VFS.
 boolean isFile()
          Whether it is a file in the VFS.
 InputStream openStream()
          Access the file contents.
 URL toURL()
          Get the VF URL (vfs:/root/org/jboss/X.java)
 

Method Detail

getName

String getName()
Get the simple VF name (X.java)

Returns:
the simple file name
Throws:
IllegalStateException - if the file is closed

getPathName

String getPathName()
Get the VFS relative path name (org/jboss/X.java)

Returns:
the VFS relative path name
Throws:
IllegalStateException - if the file is closed

isFile

boolean isFile()
               throws IOException
Whether it is a file in the VFS.

Returns:
true if a simple file.
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

isDirectory

boolean isDirectory()
                    throws IOException
Whether it is a directory in the VFS.

Returns:
true if a directory.
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

toURL

URL toURL()
          throws IOException
Get the VF URL (vfs:/root/org/jboss/X.java)

Returns:
the full URL to the VF in the VFS.
Throws:
MalformedURLException - if a url cannot be parsed
IOException - for any problem accessing the virtual file system

getStreamURL

URL getStreamURL()
                 throws IOException
Get the URL used for streaming.

Returns:
The stream URL or null if this is not the mounted root file.
Throws:
IOException

getParent

VirtualFile getParent()
                      throws IOException
Get the parent

Returns:
the parent or null if there is no parent
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

getChild

VirtualFile getChild(String path)
                     throws IOException
Get a child

Parameters:
path - the path
Returns:
the child or null if not found
Throws:
IOException - for any problem accessing the VFS
IllegalArgumentException - if the path is null
IllegalStateException - if the file is closed or it is a leaf node

getChildrenRecursively

List<VirtualFile> getChildrenRecursively()
                                         throws IOException
Get all children recursively

This always uses VisitorAttributes#RECURSE

Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

getChildren

List<VirtualFile> getChildren()
                              throws IOException
Get the children

This always uses VisitorAttributes#RECURSE

Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

findEntries

Enumeration<URL> findEntries(String path,
                             String pattern,
                             boolean recurse)
                             throws IOException
Returns entries in this bundle and its attached fragments. This bundle's class loader is not used to search for entries. Only the contents of this bundle and its attached fragments are searched for the specified entries.

Throws:
IOException
See Also:
Bundle.findEntries(String path, String pattern, boolean recurse)

getEntryPaths

Enumeration<String> getEntryPaths(String path)
                                  throws IOException
Returns an Enumeration of all the paths (String objects) to entries within this bundle whose longest sub-path matches the specified path. This bundle's class loader is not used to search for entries. Only the contents of this bundle are searched.

Throws:
IOException
See Also:
Bundle.getEntryPaths(String path)

openStream

InputStream openStream()
                       throws IOException
Access the file contents.

Returns:
an InputStream for the file contents.
Throws:
IOException - for any error accessing the file system
IllegalStateException - if the file is closed

close

void close()
Close the file resources (stream, etc.)



Copyright © 2010. All Rights Reserved.