org.jboss.virtual
Class VFS

java.lang.Object
  extended by org.jboss.virtual.VFS

public class VFS
extends Object

Virtual File System

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org, Ales Justin

Constructor Summary
VFS(VFSContext context)
          Create a new VFS.
 
Method Summary
static VirtualFile createNewRoot(URI rootURI)
          Create new root
static VirtualFile createNewRoot(URL rootURL)
          Create new root
 boolean equals(Object obj)
           
 VirtualFile findChild(String path)
          Deprecated. use getChild, and handle null if not found
 VirtualFile getChild(String path)
          Get a child
 List<VirtualFile> getChildren()
          Get the children
 List<VirtualFile> getChildren(VirtualFileFilter filter)
          Get the children
 List<VirtualFile> getChildrenRecursively()
          Get all the children recursively
 List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter)
          Get all the children recursively
 VirtualFile getRoot()
          Get the root file of this VFS
static VirtualFile getRoot(URI rootURI)
          Get the root virtual file
static VirtualFile getRoot(URL rootURL)
          Get the root virtual file
static VFS getVFS(URI rootURI)
          Get the virtual file system for a root uri
static VFS getVFS(URL rootURL)
          Get the virtual file system for a root url
static VirtualFile getVirtualFile(URI rootURI, String name)
          Get a virtual file
static VirtualFile getVirtualFile(URL rootURL, String name)
          Get a virtual file
 int hashCode()
           
static void init()
          Initialize VFS protocol handlers package property.
 void setExceptionHandler(ExceptionHandler exceptionHandler)
          Set exception handler.
 String toString()
           
protected  void visit(VirtualFile file, VirtualFileVisitor visitor)
          Visit the virtual file system
 void visit(VirtualFileVisitor visitor)
          Visit the virtual file system from the root
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VFS

public VFS(VFSContext context)
Create a new VFS.

Parameters:
context - the context
Throws:
IllegalArgumentException - for a null context
Method Detail

init

public static void init()
Initialize VFS protocol handlers package property.


setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)
Set exception handler.

Parameters:
exceptionHandler - the exception handler.

getVFS

public static VFS getVFS(URI rootURI)
                  throws IOException
Get the virtual file system for a root uri

Parameters:
rootURI - the root URI
Returns:
the virtual file system
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL is null

createNewRoot

public static VirtualFile createNewRoot(URI rootURI)
                                 throws IOException
Create new root

Parameters:
rootURI - the root url
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL

getRoot

public static VirtualFile getRoot(URI rootURI)
                           throws IOException
Get the root virtual file

Parameters:
rootURI - the root uri
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL is null

getVirtualFile

public static VirtualFile getVirtualFile(URI rootURI,
                                         String name)
                                  throws IOException
Get a virtual file

Parameters:
rootURI - the root uri
name - the path name
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL or name is null

getVFS

public static VFS getVFS(URL rootURL)
                  throws IOException
Get the virtual file system for a root url

Parameters:
rootURL - the root url
Returns:
the virtual file system
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL is null

createNewRoot

public static VirtualFile createNewRoot(URL rootURL)
                                 throws IOException
Create new root

Parameters:
rootURL - the root url
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL

getRoot

public static VirtualFile getRoot(URL rootURL)
                           throws IOException
Get the root virtual file

Parameters:
rootURL - the root url
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL

getVirtualFile

public static VirtualFile getVirtualFile(URL rootURL,
                                         String name)
                                  throws IOException
Get a virtual file

Parameters:
rootURL - the root url
name - the path name
Returns:
the virtual file
Throws:
IOException - if there is a problem accessing the VFS
IllegalArgumentException - if the rootURL or name is null

getRoot

public VirtualFile getRoot()
                    throws IOException
Get the root file of this VFS

Returns:
the root
Throws:
IOException - for any problem accessing the VFS

findChild

@Deprecated
public VirtualFile findChild(String path)
                      throws IOException
Deprecated. use getChild, and handle null if not found

Find a child from the root

Parameters:
path - the child path
Returns:
the child
Throws:
IOException - for any problem accessing the VFS (including the child does not exist)
IllegalArgumentException - if the path is null

getChild

public VirtualFile getChild(String path)
                     throws IOException
Get a child

Parameters:
path - the child path
Returns:
the child or null if not found
Throws:
IOException - if a real problem occurs

getChildren

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

Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system

getChildren

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

Parameters:
filter - to filter the children
Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system

getChildrenRecursively

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

This always uses VisitorAttributes.RECURSE

Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system

getChildrenRecursively

public List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter)
                                         throws IOException
Get all the children recursively

This always uses VisitorAttributes.RECURSE

Parameters:
filter - to filter the children
Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system

visit

public void visit(VirtualFileVisitor visitor)
           throws IOException
Visit the virtual file system from the root

Parameters:
visitor - the visitor
Throws:
IOException - for any problem accessing the VFS
IllegalArgumentException - if the visitor is null

visit

protected void visit(VirtualFile file,
                     VirtualFileVisitor visitor)
              throws IOException
Visit the virtual file system

Parameters:
file - the file
visitor - the visitor
Throws:
IOException - for any problem accessing the VFS
IllegalArgumentException - if the file or visitor is null

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2009 JBoss, A division of Red Hat, Inc. All Rights Reserved.