Class RamFileSystem
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.provider.AbstractFileSystem
-
- org.apache.commons.vfs2.provider.ram.RamFileSystem
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Serializable
,java.lang.AutoCloseable
,FileSystem
,VfsComponent
public class RamFileSystem extends AbstractFileSystem implements java.io.Serializable
A RAM File System.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<FileName,RamFileData>
cache
Cache of RAM File Dataprivate static long
serialVersionUID
serialVersionUID format is YYYYMMDD for the date of the last binary change.
-
Constructor Summary
Constructors Modifier Constructor Description protected
RamFileSystem(FileName rootName, FileSystemOptions fileSystemOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCapabilities(java.util.Collection<Capability> caps)
Adds the capabilities of this file system.void
attach(RamFileObject fo)
void
close()
Close the RAMFileSystem.protected FileObject
createFile(AbstractFileName name)
Creates a file object.(package private) void
delete(RamFileObject file)
Delete a filevoid
importTree(java.io.File file)
Import a Tree.(package private) java.lang.String[]
listChildren(FileName name)
(package private) void
rename(RamFileObject from, RamFileObject to)
(package private) void
save(RamFileObject file)
Saves a file(package private) long
size()
private void
toRamFileObject(FileObject fo, FileObject root)
Import the given file with the name relative to the given root-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileSystem
addJunction, addListener, closeCommunicationLink, decorateFileObject, doCloseCommunicationLink, doReplicateFile, fireFileChanged, fireFileCreated, fireFileDeleted, getAttribute, getFileFromCache, getFileSystemManager, getFileSystemOptions, getLastModTimeAccuracy, getParentLayer, getRoot, getRootName, getRootURI, hasCapability, init, isOpen, isReleaseable, notifyAllStreamsClosed, putFileToCache, removeFileFromCache, removeJunction, removeListener, replicateFile, resolveFile, resolveFile, setAttribute
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
serialVersionUID format is YYYYMMDD for the date of the last binary change.- See Also:
- Constant Field Values
-
cache
private final java.util.Map<FileName,RamFileData> cache
Cache of RAM File Data
-
-
Constructor Detail
-
RamFileSystem
protected RamFileSystem(FileName rootName, FileSystemOptions fileSystemOptions)
- Parameters:
rootName
- The root file name.fileSystemOptions
- The FileSystem options.
-
-
Method Detail
-
createFile
protected FileObject createFile(AbstractFileName name) throws java.lang.Exception
Description copied from class:AbstractFileSystem
Creates a file object.This method is called only if the requested file is not cached.
- Specified by:
createFile
in classAbstractFileSystem
- Parameters:
name
- name referencing the new file.- Returns:
- new created FileObject.
- Throws:
java.lang.Exception
- might throw an Exception, which is then wrapped in FileSystemException.
-
addCapabilities
protected void addCapabilities(java.util.Collection<Capability> caps)
Description copied from class:AbstractFileSystem
Adds the capabilities of this file system.- Specified by:
addCapabilities
in classAbstractFileSystem
- Parameters:
caps
- collections of Capabilities, can be immutable.
-
listChildren
java.lang.String[] listChildren(FileName name)
- Parameters:
name
- The name of the file.- Returns:
- children The names of the children.
-
delete
void delete(RamFileObject file) throws FileSystemException
Delete a file- Parameters:
file
- theRamFileObject
file to delete.- Throws:
FileSystemException
- Thrown for file system errors.
-
save
void save(RamFileObject file) throws FileSystemException
Saves a file- Parameters:
file
- theRamFileObject
file to save.- Throws:
FileSystemException
- Thrown for file system errors.
-
rename
void rename(RamFileObject from, RamFileObject to) throws FileSystemException
- Parameters:
from
- The original file.to
- The new file.- Throws:
FileSystemException
- if an error occurs.
-
attach
public void attach(RamFileObject fo)
-
importTree
public void importTree(java.io.File file) throws FileSystemException
Import a Tree.- Parameters:
file
- The File- Throws:
FileSystemException
- if an error occurs.
-
toRamFileObject
private void toRamFileObject(FileObject fo, FileObject root) throws FileSystemException
Import the given file with the name relative to the given root- Parameters:
fo
- the sourceFileObject
file to import.root
- theFileObject
root.- Throws:
FileSystemException
- Thrown for file system errors.
-
size
long size()
- Returns:
- Returns the size of the FileSystem
-
close
public void close()
Close the RAMFileSystem.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceVfsComponent
- Overrides:
close
in classAbstractFileSystem
-
-