com.togethersoft.openapi.vfs
Interface VirtualFileManager


public interface VirtualFileManager

VirtualFileManager is used to get instances of VirtualFile and Context
and make some global operation with filesystem, as saving its cache.
Only one instance of manager exists in system. You can get it by VirtualFileManagerAccess.

Author:
TogetherSoft

Method Summary
 voidaddVirtualFileListener(VirtualFileListener listener)
           
 VirtualFileContextcreateFileContext()
          Creates empty context
 VirtualFileContextcreateFileContext(PropertyMap originalContext)
          Creates context inherited from original context
 voiddiscardAllCaches(VirtualFileContext context)
          Discards any changes made to files but do not reload files from disk.
 voidexternalUpdate(VirtualFile root, boolean recursive)
          Checks timestamps of file(s) on disk and (re)load their contents if file(s) were updated.
 voidexternalUpdateAll(VirtualFileContext context)
          Checks timestamps of file(s) on disk and (re)load their contents if file(s) were updated.
 VirtualFileManagerContextgetContext()
          Return default context for storing shared properties
 VirtualFileErrorUIgetErrorUI()
           
 VirtualFilegetVirtualFile(String url)
          Gets VirtualFile with empty context.
 VirtualFilegetVirtualFile(String url, VirtualFileContext context)
          Gets VirtualFile with specified context.
 VirtualFilegetVirtualFile(String parentUrl, String relativePath, VirtualFileContext context)
          Derive file full name from parent full name and relative path.
 VirtualFilegetVirtualFile(VirtualFile parent, String relativePath)
          Gets VirtualFile with full name, derived from parent full
name and relativePath.
 booleanisAbsolutePath(String path)
           
 VirtualFileVolumemount(String root)
          mounting of a new volume representing by folder named "root"
 voidremoveVirtualFileListener(VirtualFileListener listener)
           
 voidsaveAllCaches(VirtualFileContext context)
          Writes all unsaved caches to disk.
 voidsetErrorUI(VirtualFileErrorUI ui)
          Register error UI globaly for all operations.
 VirtualFileEnumerationunsavedFiles(VirtualFileContext context)
          Returns enumeration of files, whose cache is to be written to disk.
 VirtualFileEnumerationunsavedFiles()
           

Method Detail

addVirtualFileListener

public void addVirtualFileListener(VirtualFileListener listener)

createFileContext

public VirtualFileContext createFileContext()
Creates empty context
Returns: new empty context

createFileContext

public VirtualFileContext createFileContext(PropertyMap originalContext)
Creates context inherited from original context
Returns: new inherited context

discardAllCaches

public void discardAllCaches(VirtualFileContext context)
throws java.io.IOException
Discards any changes made to files but do not reload files from disk.

externalUpdate

public void externalUpdate(VirtualFile root, boolean recursive)
throws java.io.IOException
Checks timestamps of file(s) on disk and (re)load their contents if file(s) were updated.
Simultanious modification of file in memory and on disk causes conflict, which is solved by mean of
VirtualFileErrorUI

externalUpdateAll

public void externalUpdateAll(VirtualFileContext context)
throws java.io.IOException
Checks timestamps of file(s) on disk and (re)load their contents if file(s) were updated.
Simultanious modification of file in memory and on disk causes conflict, which is solved by mean of
VirtualFileErrorUI

getContext

public VirtualFileManagerContext getContext()
Return default context for storing shared properties
Returns: shared context

getErrorUI

public VirtualFileErrorUI getErrorUI()
Returns: last time registered VirtualFileErrorUI.

getVirtualFile

public VirtualFile getVirtualFile(String url)
Gets VirtualFile with empty context. File may or maynot exist.


url param is URL of requested file. This realization supports only one URL scheme: 'file'.
It's assumed, that everything after "file:" is PATH in local file system. On Windows platforms native fullname of file (with all backslashes) can be used as PATH. Optionally it can have "//" prefix. On Unix platforms native fullname of file is allowed in file: URL. The number of leading slashes shouldn't be less than one.

On every platform url in form, returned by file.toURL().
toString()
, where file is an instance of java.io.File, is accepted.


Currently that's exactly what getUrl method would return.

In this realization fullpath alone is also applicable as url param.

For unsupported url scheme method returns instance, which throws IOException nearly in all operation.

Parameters:
url URL of file being requested
Returns: new instance of VirtualFile with specified full name

getVirtualFile

public VirtualFile getVirtualFile(String url, VirtualFileContext context)
Gets VirtualFile with specified context. File may or maynot exist.
Parameters:
url URL of file being requested
context context, which will be assigned to new VirtualFile
Returns: new instance of VirtualFile with specified full name

getVirtualFile

public VirtualFile getVirtualFile(String parentUrl, String relativePath, VirtualFileContext context)
Derive file full name from parent full name and relative path. Create VirtualFile as
described in getVirtualFile(String fullName, VirtualFileContext context)
Parameters:
relativePath path, which can contain '..' entries. Note that this path
shall be formed independently of VirtualFileType of file
Returns: new instance of VirtualFile with specified full name

getVirtualFile

public VirtualFile getVirtualFile(VirtualFile parent, String relativePath)
Gets VirtualFile with full name, derived from parent full
name and relativePath. New VirtualFile inherites parent's context.
Parameters:
parent VirtualFile, whose full name is used as base full name. Note that this path
shall be formed independently of VirtualFileType of file
relativePath path, which can contain '..' entries
Returns: new instance of VirtualFile with specified full name

isAbsolutePath

public boolean isAbsolutePath(String path)

mount

public VirtualFileVolume mount(String root)
mounting of a new volume representing by folder named "root"

removeVirtualFileListener

public void removeVirtualFileListener(VirtualFileListener listener)

saveAllCaches

public void saveAllCaches(VirtualFileContext context)
throws java.io.IOException
Writes all unsaved caches to disk. Files on disk may be created at this moment.

setErrorUI

public void setErrorUI(VirtualFileErrorUI ui)
Register error UI globaly for all operations.

unsavedFiles

public VirtualFileEnumeration unsavedFiles(VirtualFileContext context)
Returns enumeration of files, whose cache is to be written to disk.

unsavedFiles

public VirtualFileEnumeration unsavedFiles()