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

Constructor Summary
VFS(VFSContext context)
          Create a new VFS.
 
Method Summary
 boolean equals(Object obj)
           
 VirtualFile findChild(String path)
          Find a child from the root
 VirtualFile findChildFromRoot(String path)
          Deprecated. 
 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()
           
 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()

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

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

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

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

public VirtualFile findChild(String path)
                      throws IOException
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

findChildFromRoot

@Deprecated
public VirtualFile findChildFromRoot(String path)
                              throws IOException
Deprecated. 

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

getChildren

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

Returns:
the children
Throws:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the root is a leaf node

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
IllegalStateException - if the root is a leaf node

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
IllegalStateException - if the root is a leaf node

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
IllegalStateException - if the root is a leaf node

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
IllegalStateException - if the root is a leaf node

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
IllegalStateException - if the root is a leaf node

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 © 2007 JBoss, A division of Red Hat, Inc. All Rights Reserved.