org.jboss.virtual.plugins.context.memory
Class MemoryContextHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
      extended by org.jboss.virtual.plugins.context.AbstractURLHandler
          extended by org.jboss.virtual.plugins.context.memory.MemoryContextHandler
All Implemented Interfaces:
Serializable, StructuredVirtualFileHandler, VirtualFileHandler

public class MemoryContextHandler
extends AbstractURLHandler
implements StructuredVirtualFileHandler

Virtual memory context handler.

Version:
$Revision: 1.1 $
Author:
Kabir Khan
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log
 
Constructor Summary
MemoryContextHandler(VFSContext context, VirtualFileHandler parent, URL url, String name)
           
 
Method Summary
protected  void addChild(String name, MemoryContextHandler child)
           
 VirtualFileHandler createChildHandler(String name)
          Called by structuredFindChild
 boolean exists()
          Basis existence on URLConnection.getLastModified() != 0.
 VirtualFileHandler getChild(String path)
          Get a child
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
protected  void initCacheLastModified()
           
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 boolean isNested()
          Are we nested in some archive.
 InputStream openStream()
          Access the file contents.
 boolean removeChild(String name)
          Remove a child
 void setContents(byte[] contents)
           
 URL toVfsUrl()
          Get a VFS-based URL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
getURL, isHidden, openConnection, openConnection, toURI, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, checkParentExists, cleanup, close, decrement, delete, doClose, equals, getChildPathName, getChildVfsUrl, getLocalPathName, getLocalVFSContext, getName, getParent, getPathName, getRealURL, getReferences, getVFSContext, getVfsUrl, getVirtualFile, hasBeenModified, hashCode, increment, internalReplaceChild, isArchive, isTemporary, replaceChild, setPathName, setVfsUrl, simpleFindChild, structuredFindChild, toInternalVfsUrl, toString, toStringLocal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryContextHandler

public MemoryContextHandler(VFSContext context,
                            VirtualFileHandler parent,
                            URL url,
                            String name)
Method Detail

addChild

protected void addChild(String name,
                        MemoryContextHandler child)

getChildren

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

Specified by:
getChildren in interface VirtualFileHandler
Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
IOException - for an error accessing the file system

isLeaf

public boolean isLeaf()
Description copied from interface: VirtualFileHandler
Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

Specified by:
isLeaf in interface VirtualFileHandler
Returns:
true if a simple file.

createChildHandler

public VirtualFileHandler createChildHandler(String name)
                                      throws IOException
Called by structuredFindChild

Specified by:
createChildHandler in interface StructuredVirtualFileHandler
Parameters:
name - the name
Returns:
the handler
Throws:
IOException - for any error accessing the virtual file system

getChild

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

Specified by:
getChild in interface VirtualFileHandler
Parameters:
path - the path
Returns:
the child or null if not found
Throws:
IOException - for an error accessing the file system

removeChild

public boolean removeChild(String name)
                    throws IOException
Description copied from interface: VirtualFileHandler
Remove a child

Specified by:
removeChild in interface VirtualFileHandler
Parameters:
name - child name
Returns:
true if child was removed, false otherwise
Throws:
IOException - if an error occurs

exists

public boolean exists()
               throws IOException
Description copied from class: AbstractURLHandler
Basis existence on URLConnection.getLastModified() != 0. This may not be true for all url connections.

Specified by:
exists in interface VirtualFileHandler
Overrides:
exists in class AbstractURLHandler
Returns:
true if the file exists, false otherwise.
Throws:
IOException - - thrown on failure to detect existence.
See Also:
URLConnection.getLastModified(), org.jboss.test.virtual.test.URLExistsUnitTestCase

setContents

public void setContents(byte[] contents)

initCacheLastModified

protected void initCacheLastModified()
Overrides:
initCacheLastModified in class AbstractURLHandler

getSize

public long getSize()
             throws IOException
Description copied from interface: VirtualFileHandler
Get the size

Specified by:
getSize in interface VirtualFileHandler
Overrides:
getSize in class AbstractURLHandler
Returns:
the size
Throws:
IOException - for any problem accessing the virtual file system

getLastModified

public long getLastModified()
                     throws IOException
Description copied from interface: VirtualFileHandler
When the file was last modified

Specified by:
getLastModified in interface VirtualFileHandler
Overrides:
getLastModified in class AbstractURLHandler
Returns:
the last modified time
Throws:
IOException - for any problem accessing the virtual file system

isNested

public boolean isNested()
                 throws IOException
Description copied from interface: VirtualFileHandler
Are we nested in some archive.

Specified by:
isNested in interface VirtualFileHandler
Returns:
true if this is archive entry
Throws:
IOException - for any error

openStream

public InputStream openStream()
                       throws IOException
Description copied from interface: VirtualFileHandler
Access the file contents.

Specified by:
openStream in interface VirtualFileHandler
Overrides:
openStream in class AbstractURLHandler
Returns:
An InputStream for the file contents.
Throws:
IOException - for any problem accessing the virtual file system

toVfsUrl

public URL toVfsUrl()
             throws MalformedURLException,
                    URISyntaxException
Description copied from interface: VirtualFileHandler
Get a VFS-based URL

Specified by:
toVfsUrl in interface VirtualFileHandler
Overrides:
toVfsUrl in class AbstractVirtualFileHandler
Returns:
the url
Throws:
MalformedURLException - for any error
URISyntaxException - for an error parsing the URI


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