|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.vfs.VFS
The VFS, or Virtual File System, is responsible for mapping a Url to a buffer representing its contents. The VFS serves as a global cache of Buffer instances, mapping Url descriptions to existing in-memory buffers when possible, and creating new buffers as necessary.
All attempts to manipulate a Url through the VFS are directed to the filesystem associated with the Url.
Buffer
,
Filesystem
Method Summary | |
static void |
addVFSListener(VFSListener listener)
Adds a VFSListener to the list of listeners that receive VFS events. |
static void |
copy(Url sourceUrl,
Url targetUrl)
Copies a resource, duplicating both the state of buffers and the persistant storage state. |
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
Deprecated. Use Streams.copy(in, out) instead. |
static void |
delete(Url url)
Deletes the specified resource from permanent storage and ensures that its buffer, if in memory, has been emptied and marked as unmodified. |
static boolean |
exists(Url url)
Tests if the specified resource actually exists. |
static Buffer |
findBuffer(Url url)
Checks the cache for an existing reference to the underlying buffer. |
static void |
fireBufferConflict(Buffer buffer)
Notifies all registered VFSListeners that the content of the buffer has been changed in memory and on disk and that the resulting conflict needs to be resolved. |
static Buffer |
getBuffer(Url url)
Returns an instance of the appropriate Buffer subclass to represent the contents of a Url. |
static Url |
getCanonicalUrl(Url url)
Reports the exact Url representation of a resource. |
static Url[] |
getChildren(Url url,
int type)
Retrieves a list of children within a resource, such as files within a directory. |
static Url[] |
getChildren(Url url,
RegularExpression[] patterns,
int type)
Retrieves a list of children within a resource, such as files within a directory. |
static Url[] |
getChildren(Url url,
RegularExpression pattern,
int type)
Retrieves a list of children within a resource, such as files within a directory. |
static java.io.InputStream |
getInputStream(Url url)
Creates an InputStream that reads from the specified Url. |
static long |
getLastModified(Url url)
Reports the time at which the contents of this resource were last modified. |
static java.io.OutputStream |
getOutputStream(Url url)
Creates an OutputStream that writes to the specified Url. |
static java.io.OutputStream |
getOutputStream(Url url,
boolean createBackup)
Creates an OutputStream that writes to the specified Url. |
static boolean |
isDirectory(Url url)
Tests if the specified resource represents a container of other resources. |
static boolean |
isReadOnly(Url url)
Tests if the specified resource is read-only. |
static void |
removeVFSListener(VFSListener listener)
Removes a VFSListener from the list of listeners that receive VFS events. |
static void |
rename(Url oldUrl,
Url newUrl)
Renames a resource by making a copy and deleting the original. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void copyStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
public static Buffer getBuffer(Url url) throws java.io.IOException
revert
method.url
- The resource for which a buffer is desired.java.io.IOException
- If the specified resource could not be
read.public static Buffer findBuffer(Url url)
url
- The Url key used to locate the desired buffer.public static java.io.InputStream getInputStream(Url url) throws java.io.IOException
url
- The resource to be read.java.io.IOException
- If the Url specifies a resource that could
not be read, or if no matching filesystem could be found for the Url.public static java.io.OutputStream getOutputStream(Url url, boolean createBackup) throws java.io.IOException
getBuffer
and use its
getOutputStream
method instead.If createBackup is set to true and the url is saved to disk, it will be saved using a multi-level "~nn~" backup, where nn is the backup count.
Use this method for saving url's with either no backup or a multilevel
backup. For a single level tilde "~" backup use the next
getOutputStream
method.
url
- The resource to be written.createBackup
- True if a multi-level backup file should be created,
false if no backups should be created.java.io.IOException
- If the Url specifies a resource that could
not be written to.public static java.io.OutputStream getOutputStream(Url url) throws java.io.IOException
getBuffer
and use its
getOutputStream
method instead.If it is saved to disk, it will be saved using a single level tilde "~" backup.
Use this method for saving url's with only a single level backup. For a
multilevel backup or no backup at all, use the previous
getOutputStream
method.
url
- The resource to be written.java.io.IOException
- If the Url specifies a resource that could
not be written to.public static boolean isReadOnly(Url url)
url
- The resource to be tested.public static long getLastModified(Url url)
url
- The resource to be tested.public static Url getCanonicalUrl(Url url)
url
- The resource.public static boolean exists(Url url)
url
- The resource to be tested.public static boolean isDirectory(Url url)
url
- The resource to be tested.public static Url[] getChildren(Url url, int type)
Retrieves a list of children within a resource, such as files within a directory.
url
- The container resource.type
- The Filesystem constants TYPE_DIRECTORY
,
TYPE_FILE
, and TYPE_BOTH
can be used to control
the type of resources that are represented in the result array.public static Url[] getChildren(Url url, RegularExpression pattern, int type)
Retrieves a list of children within a resource, such as files within a directory.
url
- The container resource.pattern
- A regular expression constraining the set of values that
will be returned. Only children whose final path component exactly
matches the pattern will be represented in the resulting array. Note that
directories are not compared against the pattern, only files.type
- The Filesystem constants TYPE_DIRECTORY
,
TYPE_FILE
, and TYPE_BOTH
can be used to control
the type of resources that are represented in the result array.public static Url[] getChildren(Url url, RegularExpression[] patterns, int type)
Retrieves a list of children within a resource, such as files within a directory.
url
- The container resource.pattern
- An array of regular expressions constraining the set of
values that will be returned. Only children whose final path component
exactly matches at least one of the patterns will be represented in the
resulting array. Note that a null array matches all children and that
directories are not compared against the patterns, only files.type
- The Filesystem constants TYPE_DIRECTORY
,
TYPE_FILE
, and TYPE_BOTH
can be used to control
the type of resources that are represented in the result array.public static void delete(Url url) throws java.io.IOException
url
- The resource to be deleted.java.io.IOException
- If the Url specifies a resource that could
not be deleted.public static void rename(Url oldUrl, Url newUrl) throws java.io.IOException, java.io.FileNotFoundException, ReadOnlyException
sourceUrl
- The resource's current Url.desinationUrl
- The resource's desired Url.java.io.IOException
- If the resource could not be renamed due
to a read or write error, or the source is read-only, or the target Url
already exists.java.io.FileNotFoundException
- If the source does not exist as
either a buffer in the VFS or a resource in a filesystem.public static void copy(Url sourceUrl, Url targetUrl) throws java.io.IOException
If the target Url already exists, copy will silently overwrite it.
sourceUrl
- The resource to copy from.targetUrl
- The resource to copy to.java.io.IOException
- If the resource could not be copied due
to a read or write error.java.io.FileNotFoundException
- If the source does not exist as
either a buffer in the VFS or a resource in a filesystem.public static void addVFSListener(VFSListener listener)
listener
- The listener.public static void removeVFSListener(VFSListener listener)
listener
- The listener.public static void fireBufferConflict(Buffer buffer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |