| ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This class represents a file (or directory) of VirtualFileSystem. Like java.io.File, the instance of
VirtualFile can correspond to unexistent file. Files of VFS are cached and not necessarily are written or even
exists on disk. Different instances of VirtualFile can represent same file.
Each instance has a Context; however the contexts are not used currently.
VirtualFile has a number of properties. Custom properties are not supported now. The predefined properties
are listed in VirtualFileProperty.
| Method Summary | |
void | addVirtualFileListener(VirtualFileListener listener, int depth)Adds VirtualFileListener to a file |
VirtualFileEnumeration | children()Returns children of invoking VirtualFile, which must be directory. |
VirtualFileEnumeration | children(VirtualFileFilter filter)Extension of children (UnatyPredicate). |
VirtualFile | copy(VirtualFile newParent, boolean overwrite)Copies VirtualFile to another directory. |
void | create(VirtualFileType fileType, boolean overwrite)Creates file or directory if it didn't exist yet. |
void | delete()Deletes file from memory and disk. |
void | discardCache()Discards any changes made to cache but do not reload file from disk. |
void | discardCache(Depth depth)Discards any changes made to cache but do not reload file from disk. |
boolean | exists()Returns true if the file exists either on disk or in memory. |
void | externalUpdate(Depth depth)Not supported now Checks timestamps of file(s) on disk and (re)load their contents if file(s) were updated. |
byte[] | getArrayOfBytes()Reads the whole file, saving cache if needed, and returns the read array of bytes. |
VirtualFile | getChild(String shortName)Does exactly the same as VirtualFileManager method getVirtualFile(VirtualFile parent, String
, but with default context. |
VirtualFileContext | getContext()Return instnace of Context, assigned to this VirtualFile |
String | getExtension() |
String | getFullName()Shortcut for FILE_FULL_NAME property getting. |
InputStream | getInputStream() |
OutputStream | getOutputStream()Returns output stream. |
VirtualFile | getParent() |
String | getPathRelativeTo(VirtualFile from)* |
int | getPermission()Shortcut for FILE_PERMISSION property getting. |
Reader | getReader() |
String | getShortName()Shortcut for FILE_SHORT_NAME property getting. |
VirtualFileType | getType()Shortcut for FILE_TYPE property getting. |
VirtualFile | getUniqueChild(String prefix, String extension)Gets unique child named on the base of prefix and extension |
String | getUrl()Shortcut for FILE_URL property getting. |
VirtualFileManager | getVirtualFileManager()Returns VirtualFileManager instance |
Writer | getWriter()Returns Writer for VirtualFile. |
boolean | hasChild(String name)Checks if the file has child named name |
boolean | isAncestorOf(VirtualFile descendant) |
boolean | isCacheDirty()Returns true if changes were made to cache since file was opened or cache saved/discarded. |
VirtualFile | move(VirtualFile newParent, boolean overwrite)Moves the VirtualFile to another virtual file which must exist and be a directory. |
void | removeVirtualFileListener(VirtualFileListener listener)Removes listener |
void | saveCache()Save all changes in cache to disk. |
void | saveCache(Depth depth)Save all changes in cache to disk. |
void | setArrayOfBytes(byte[] array)Notice: (in current realization) in any case, only value of array would be used in VFS. |
void | setShortName(String newName)Shortcut for FILE_SHORT_NAME property setting. |
void | touchContent()Increases the internal cache age by one, that is file is treated as modified. |
| Methods inherited from interface com.togethersoft.openapi.util.propertyMap.PropertyMap |
addProperty, addPropertyMapListener, canAddProperty, canSetPropertyValue, getPropertyValue, getPropertyValue, isPropertyReadable, isPropertyWritable, properties, properties, removePropertyMapListener, setPropertyValue |
| Method Detail |
public void addVirtualFileListener(VirtualFileListener listener, int depth)
VirtualFileListener to a filepublic VirtualFileEnumeration children()
throws java.io.IOException
VirtualFile, which must be directory. Children are returned as enumeration of
VirtualFiles. The child can exists either on disk or in memory.IOException when list of children cannot be obtained. Eg, when this
public VirtualFileEnumeration children(VirtualFileFilter filter)
throws java.io.IOException
filer.accept(VirtualFile) method returns true.IOException when list of children cannot be obtained. Eg, when this isn't directory.public VirtualFile copy(VirtualFile newParent, boolean overwrite)
throws java.io.IOException
VirtualFile to another directory.move(...) method.newParent destination directory;overwrite specifies, if existent file can be overwritten;VirtualFile of copied file.IOException if copying was unsuccessful.public void create(VirtualFileType fileType, boolean overwrite)
throws java.io.IOException
overwrite specifies, if existent file should be overwrittenIOException if file wasn't created for any reason.public void delete()
throws java.io.IOException
VirtualFile became unexistent, i.e. exists method returns false.public void discardCache()
throws java.io.IOException
public void discardCache(Depth depth)
throws java.io.IOException
Bugs:
StackOverflowError in this method with depth == Depth.INFINITY .
depth defines, if the command should be recursive.public boolean exists()
public void externalUpdate(Depth depth)
throws java.io.IOException
depth defines, if the command should be recursive.public byte[] getArrayOfBytes()
throws java.io.IOException
public VirtualFile getChild(String shortName)
VirtualFileManager method getVirtualFile(VirtualFile parent, String
relativePath, VirtualFileContext context), but with default context.public VirtualFileContext getContext()
Context, assigned to this VirtualFilepublic String getExtension()
public String getFullName()
public InputStream getInputStream()
throws java.io.IOException
InputStream which can be used to read file contents.public OutputStream getOutputStream()
throws java.io.IOException
public VirtualFile getParent()
VirtualFile for parent directory or null when applied to root directory.public String getPathRelativeTo(VirtualFile from)
VirtualFile gived as a parameter. Note that relative path
FILE_TYPE of it is VirtualFileType.DIRECTORY or
VirtualFileType.FILEpublic int getPermission()
public Reader getReader()
throws java.io.IOException
Reader which can be used to read file contents.public String getShortName()
public VirtualFileType getType()
public VirtualFile getUniqueChild(String prefix, String extension)
throws java.io.IOException
prefix and extensionVirtualFile object representing file named prefixNUMBER.extension.public String getUrl()
public VirtualFileManager getVirtualFileManager()
VirtualFileManager instancepublic Writer getWriter()
throws java.io.IOException
Writer for VirtualFile. It should be closed in order to allow flushing. Opened writer
public boolean hasChild(String name)
namepublic boolean isAncestorOf(VirtualFile descendant)
true if invoking object is ancestor of descendant.public boolean isCacheDirty()
public VirtualFile move(VirtualFile newParent, boolean overwrite)
throws java.io.IOException
VirtualFile to another virtual file which must exist and be a directory.
newParent destination directory;overwrite specifies, if existent file can be overwritten;IOException if VirtualFile cannot be moved.VirtualFile of file in its new location.public void removeVirtualFileListener(VirtualFileListener listener)
public void saveCache()
throws java.io.IOException
public void saveCache(Depth depth)
throws java.io.IOException
depth defines, if the command should be recursive.public void setArrayOfBytes(byte[] array)
throws java.io.IOException
array would be used in VFS. Unlike
getArrayOfBytes, original instance of array can be modified free without influence VFS cache system.public void setShortName(String newName)
throws java.io.IOException
public void touchContent()
| ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||