org.jboss.virtual.plugins.context
Class AbstractVFSContext

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVFSContext
All Implemented Interfaces:
VFSContext
Direct Known Subclasses:
AssembledContext, FileSystemContext, JarContext, MemoryContext, ZipEntryContext

public abstract class AbstractVFSContext
extends Object
implements VFSContext

AbstractVFSContext.

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

Field Summary
protected  org.jboss.logging.Logger log
          The log
 
Constructor Summary
protected AbstractVFSContext(URI rootURI)
          Create a new AbstractVFSContext.
protected AbstractVFSContext(URL rootURL)
          Create a new AbstractVFSContext.
 
Method Summary
 void addTempInfo(TempInfo tempInfo)
          Add temp info.
 void cleanupTempInfo(String path)
          Cleanup all temp infos under path param.
protected  Options createNewOptions()
          Create options.
 boolean equals(Object obj)
           
 VirtualFileHandler getChild(VirtualFileHandler parent, String path)
          Get a child
 List<VirtualFileHandler> getChildren(VirtualFileHandler parent, boolean ignoreErrors)
          Get the children
 URL getChildURL(VirtualFileHandler parent, String name)
          Construct a URL from a given parent and a name
 Set<VFSContextConstraints> getConstraints()
          Get context's constraints.
 ExceptionHandler getExceptionHandler()
          Get the exception handler.
 TempInfo getFurthestParentTemp(String path)
          Retrieve the furthest (outter most) temp which contains this path.
protected
<T> T
getOption(Class<T> expectedType)
           
protected  Object getOption(String name)
           
protected
<T> T
getOption(String name, Class<T> expectedType)
           
 Options getOptions()
          Get options.
protected  VFSContext getPeerContext()
          Get peer vfs context.
 VirtualFileHandler getRootPeer()
          Return the peer representing the root of this context within another context.
 URI getRootURI()
          Get the root uri
 TempInfo getTempInfo(String path)
          Get exact temp info match.
 Iterable<TempInfo> getTempInfos()
          Iterate over all temp infos.
 VFS getVFS()
          Get the VFS for this context
 int hashCode()
           
 void setExceptionHandler(ExceptionHandler exceptionHandler)
          Set exception handler.
protected  void setOption(String name, Object option)
           
protected  URL setOptionsToURL(URL url)
          Helper method to set options on an URL
 void setRootPeer(VirtualFileHandler handler)
           
 String toString()
           
 void visit(VirtualFileHandler handler, VirtualFileHandlerVisitor visitor)
          Visit the virtual file system
protected  void visit(VirtualFileHandler handler, VirtualFileHandlerVisitor visitor, boolean includeRoot, boolean leavesOnly, boolean ignoreErrors, boolean includeHidden, VirtualFileFilter recurseFilter)
          Visit.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.virtual.spi.VFSContext
getName, getRoot
 

Field Detail

log

protected final org.jboss.logging.Logger log
The log

Constructor Detail

AbstractVFSContext

protected AbstractVFSContext(URI rootURI)
Create a new AbstractVFSContext.

Parameters:
rootURI - the root url
Throws:
IllegalArgumentException - if rootURI is null

AbstractVFSContext

protected AbstractVFSContext(URL rootURL)
                      throws URISyntaxException
Create a new AbstractVFSContext.

Parameters:
rootURL - the root url
Throws:
URISyntaxException - for illegal URL
IllegalArgumentException - if rootURI is null
Method Detail

getConstraints

public Set<VFSContextConstraints> getConstraints()
Description copied from interface: VFSContext
Get context's constraints.

Specified by:
getConstraints in interface VFSContext
Returns:
the constraints

createNewOptions

protected Options createNewOptions()
Create options.

Returns:
the new options

getVFS

public VFS getVFS()
Description copied from interface: VFSContext
Get the VFS for this context

Specified by:
getVFS in interface VFSContext
Returns:
the vfs

getRootURI

public URI getRootURI()
Description copied from interface: VFSContext
Get the root uri

Specified by:
getRootURI in interface VFSContext
Returns:
the root uri

setRootPeer

public void setRootPeer(VirtualFileHandler handler)

getRootPeer

public VirtualFileHandler getRootPeer()
Description copied from interface: VFSContext
Return the peer representing the root of this context within another context. Used when mounting contexts within other contexts

Specified by:
getRootPeer in interface VFSContext
Returns:
the root peer

getOptions

public Options getOptions()
Description copied from interface: VFSContext
Get options.

Specified by:
getOptions in interface VFSContext
Returns:
the options

setOption

protected void setOption(String name,
                         Object option)

getOption

protected Object getOption(String name)

getOption

protected <T> T getOption(Class<T> expectedType)

getOption

protected <T> T getOption(String name,
                          Class<T> expectedType)

getPeerContext

protected VFSContext getPeerContext()
Get peer vfs context.

Returns:
the peer context

setOptionsToURL

protected URL setOptionsToURL(URL url)
                       throws MalformedURLException
Helper method to set options on an URL

Parameters:
url - url to set options on
Returns:
url with query parameters
Throws:
MalformedURLException - if url manipulation fails

getChildren

public List<VirtualFileHandler> getChildren(VirtualFileHandler parent,
                                            boolean ignoreErrors)
                                     throws IOException
Description copied from interface: VFSContext
Get the children

Specified by:
getChildren in interface VFSContext
Parameters:
parent - the parent
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
IOException - for any problem accessing the VFS

getChild

public VirtualFileHandler getChild(VirtualFileHandler parent,
                                   String path)
                            throws IOException
Description copied from interface: VFSContext
Get a child

Specified by:
getChild in interface VFSContext
Parameters:
parent - the parent
path - the path
Returns:
the child or null if not found
Throws:
IOException - for any problem accessing the VFS

getChildURL

public URL getChildURL(VirtualFileHandler parent,
                       String name)
                throws IOException
Construct a URL from a given parent and a name

Parameters:
parent - a parent
name - a name of the child
Returns:
URL corresponding to a child
Throws:
IOException - for any error

visit

public void visit(VirtualFileHandler handler,
                  VirtualFileHandlerVisitor visitor)
           throws IOException
Description copied from interface: VFSContext
Visit the virtual file system

Specified by:
visit in interface VFSContext
Parameters:
handler - the reference handler
visitor - the visitor
Throws:
IOException - for any error

visit

protected void visit(VirtualFileHandler handler,
                     VirtualFileHandlerVisitor visitor,
                     boolean includeRoot,
                     boolean leavesOnly,
                     boolean ignoreErrors,
                     boolean includeHidden,
                     VirtualFileFilter recurseFilter)
              throws IOException
Visit. the file system, recursive death checking is left to the visitor or otherwise a stack overflow.

Parameters:
handler - the reference handler
visitor - the visitor
includeRoot - whether to visit the root
leavesOnly - whether to visit leaves only
ignoreErrors - whether to ignore errors
includeHidden - whether to include hidden files
recurseFilter - the recurse filter
Throws:
IOException - for any problem accessing the virtual file system

addTempInfo

public void addTempInfo(TempInfo tempInfo)
Description copied from interface: VFSContext
Add temp info.

Specified by:
addTempInfo in interface VFSContext
Parameters:
tempInfo - the temp info

getTempInfo

public TempInfo getTempInfo(String path)
Description copied from interface: VFSContext
Get exact temp info match.

Specified by:
getTempInfo in interface VFSContext
Parameters:
path - the path to match
Returns:
temp info instance or null if not found

getFurthestParentTemp

public TempInfo getFurthestParentTemp(String path)
Description copied from interface: VFSContext
Retrieve the furthest (outter most) temp which contains this path. Ex. if there is /a/b, /a/b/c, and /a/b/c/d, you get /a/b.

Specified by:
getFurthestParentTemp in interface VFSContext
Parameters:
path - the path to match
Returns:
the furthest parent

cleanupTempInfo

public void cleanupTempInfo(String path)
Description copied from interface: VFSContext
Cleanup all temp infos under path param.

Specified by:
cleanupTempInfo in interface VFSContext
Parameters:
path - the path to cleanup

getTempInfos

public Iterable<TempInfo> getTempInfos()
Description copied from interface: VFSContext
Iterate over all temp infos. This should return lexicographically ordered temp infos.

Specified by:
getTempInfos in interface VFSContext
Returns:
ordered temp infos

getExceptionHandler

public ExceptionHandler getExceptionHandler()
Description copied from interface: VFSContext
Get the exception handler.

Specified by:
getExceptionHandler in interface VFSContext
Returns:
the exception handler

setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)
Description copied from interface: VFSContext
Set exception handler.

Specified by:
setExceptionHandler in interface VFSContext
Parameters:
exceptionHandler - the exception handler.

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