public class StubVirtualFile extends VirtualFile
VirtualFile.PropName
EMPTY_ARRAY, PROP_ENCODING, PROP_HIDDEN, PROP_NAME, PROP_SYMLINK_TARGET, PROP_WRITABLE
EVER_CHANGED, NEVER_CHANGED
Constructor and Description |
---|
StubVirtualFile() |
Modifier and Type | Method and Description |
---|---|
protected void |
clearUserData() |
byte [] |
contentsToByteArray()
Returns file content as an array of bytes.
|
VirtualFile |
copy(java.lang.Object requestor,
VirtualFile newParent,
java.lang.String copyName) |
VirtualFile |
createChildData(java.lang.Object requestor,
java.lang.String name)
Creates a new file in this directory.
|
VirtualFile |
createChildDirectory(java.lang.Object requestor,
java.lang.String name)
Creates a subdirectory in this directory.
|
void |
delete(java.lang.Object requestor)
Deletes this file.
|
VirtualFile[] |
getChildren()
Gets the child files.
|
VirtualFileSystem |
getFileSystem()
Gets the
VirtualFileSystem this file belongs to. |
java.io.InputStream |
getInputStream()
Gets the
InputStream for this file. |
long |
getLength()
File length in bytes.
|
java.lang.String |
getName()
Gets the name of this file.
|
java.io.OutputStream |
getOutputStream(java.lang.Object requestor,
long newModificationStamp,
long newTimeStamp)
Gets the
OutputStream for this file and sets modification stamp and time stamp to the specified values
after closing the stream. |
VirtualFile |
getParent()
Gets the parent
VirtualFile . |
java.lang.String |
getPath()
Gets the path of this file.
|
long |
getTimeStamp()
Gets the timestamp for this file.
|
java.lang.String |
getUrl()
Returns the URL of this file.
|
boolean |
isDirectory()
Checks whether this file is a directory.
|
boolean |
isValid()
Checks whether this
VirtualFile is valid. |
boolean |
isWritable()
Checks whether this file could be modified.
|
void |
move(java.lang.Object requestor,
VirtualFile newParent)
Moves this file to another directory.
|
<T> void |
putCopyableUserData(Key<T> key,
T value) |
<T> void |
putUserData(Key<T> key,
T value)
Add a new user data value to this object.
|
<T> T |
putUserDataIfAbsent(Key<T> key,
T value) |
void |
refresh(boolean asynchronous,
boolean recursive)
Refreshes the cached file information from the physical file system.
|
void |
refresh(boolean asynchronous,
boolean recursive,
java.lang.Runnable postRunnable)
The same as
VirtualFile.refresh(boolean, boolean) but also runs postRunnable
after the operation is completed. |
<T> boolean |
replace(Key<T> key,
T oldValue,
T newValue)
Replaces (atomically) old value in the map with the new one
|
void |
setBinaryContent(byte [] content,
long newModificationStamp,
long newTimeStamp) |
void |
setBinaryContent(byte [] content,
long newModificationStamp,
long newTimeStamp,
java.lang.Object requestor) |
void |
setBOM(byte [] BOM) |
void |
setCharset(java.nio.charset.Charset charset) |
void |
setCharset(java.nio.charset.Charset charset,
java.lang.Runnable whenChanged) |
void |
setCharset(java.nio.charset.Charset charset,
java.lang.Runnable whenChanged,
boolean fireEventsWhenChanged) |
void |
setDetectedLineSeparator(java.lang.String separator) |
void |
setPreloadedContentHint(byte[] preloadedContentHint) |
protected void |
setUserMap(KeyFMap map) |
void |
setWritable(boolean writable) |
protected void |
storeCharset(java.nio.charset.Charset charset) |
contentsToByteArray, exists, findChild, findFileByRelativePath, findOrCreateChildData, getBOM, getCanonicalFile, getCanonicalPath, getCharset, getDetectedLineSeparator, getExtension, getFileType, getModificationCount, getModificationStamp, getNameSequence, getNameWithoutExtension, getOutputStream, getPresentableName, getPresentableUrl, is, isCharsetSet, isInLocalFileSystem, isRecursiveOrCircularSymLink, isValidName, nameEquals, rename, setBinaryContent, toString
changeUserMap, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty
public byte [] contentsToByteArray() throws java.io.IOException
VirtualFile
contentsToByteArray
in class VirtualFile
java.io.IOException
- if an I/O error occursVirtualFile.contentsToByteArray(boolean)
,
VirtualFile.getInputStream()
public VirtualFile[] getChildren()
VirtualFile
getChildren
in class VirtualFile
null
if this file is not a directorypublic VirtualFileSystem getFileSystem()
VirtualFile
VirtualFileSystem
this file belongs to.getFileSystem
in class VirtualFile
VirtualFileSystem
public java.io.InputStream getInputStream() throws java.io.IOException
VirtualFile
InputStream
for this file.
Skips BOM if there is any. See Unicode Byte Order Mark FAQ for an explanation.getInputStream
in class VirtualFile
InputStream
java.io.IOException
- if an I/O error occursVirtualFile.contentsToByteArray()
public long getLength()
VirtualFile
getLength
in class VirtualFile
public java.lang.String getName()
VirtualFile
getName
in class VirtualFile
VirtualFile.getNameSequence()
public java.io.OutputStream getOutputStream(java.lang.Object requestor, long newModificationStamp, long newTimeStamp) throws java.io.IOException
VirtualFile
Gets the OutputStream
for this file and sets modification stamp and time stamp to the specified values
after closing the stream.
Normally, you should not use this method.
Writes BOM first, if there is any. See Unicode Byte Order Mark FAQ for an explanation.
getOutputStream
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
and SafeWriteRequestor
.newModificationStamp
- new modification stamp or -1 if no special value should be setnewTimeStamp
- new time stamp or -1 if no special value should be setOutputStream
java.io.IOException
- if an I/O error occursVirtualFile.getModificationStamp()
public VirtualFile getParent()
VirtualFile
VirtualFile
.getParent
in class VirtualFile
null
if this file is a root directorypublic java.lang.String getPath()
VirtualFile
VirtualFileSystem
. Format of the path depends on the concrete file system.
For LocalFileSystem
it is an absolute file path with file separator characters
(File.separatorChar
) replaced to the forward slash ('/'
).getPath
in class VirtualFile
public long getTimeStamp()
VirtualFile
getTimeStamp
in class VirtualFile
File.lastModified()
public java.lang.String getUrl()
VirtualFile
Returns the URL of this file. The URL is a string that uniquely identifies a file in all file systems.
It has the following format: <protocol>://<path>
.
File can be found by its URL using VirtualFileManager.findFileByUrl(java.lang.String)
method.
Please note these URLs are intended for use withing VFS - meaning they are not necessarily RFC-compliant.
getUrl
in class VirtualFile
VirtualFileManager.findFileByUrl(java.lang.String)
,
VirtualFile.getPath()
,
VirtualFileSystem.getProtocol()
public boolean isDirectory()
VirtualFile
isDirectory
in class VirtualFile
true
if this file is a directory, false
otherwisepublic boolean isValid()
VirtualFile
VirtualFile
is valid. File can be invalidated either by deleting it or one of its
parents with VirtualFile.delete(java.lang.Object)
method or by an external change.
If file is not valid only Object.equals(java.lang.Object)
, Object.hashCode()
,
VirtualFile.getName()
, VirtualFile.getPath()
, VirtualFile.getUrl()
, VirtualFile.getPresentableUrl()
and methods from
UserDataHolder
can be called for it. Using any other methods for an invalid VirtualFile
instance
produce unpredictable results.isValid
in class VirtualFile
true
if this is a valid file, false
otherwisepublic boolean isWritable()
VirtualFile
isWritable
in class VirtualFile
true
if this file is writable, false
otherwisepublic void refresh(boolean asynchronous, boolean recursive, java.lang.Runnable postRunnable)
VirtualFile
VirtualFile.refresh(boolean, boolean)
but also runs postRunnable
after the operation is completed. The runnable is executed on event dispatch thread inside write action.refresh
in class VirtualFile
public void setWritable(boolean writable)
setWritable
in class VirtualFile
public VirtualFile createChildDirectory(java.lang.Object requestor, java.lang.String name)
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.createChildDirectory
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
name
- directory nameVirtualFile
representing the created directorypublic VirtualFile createChildData(java.lang.Object requestor, java.lang.String name)
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.createChildData
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
VirtualFile
representing the created filepublic void delete(java.lang.Object requestor)
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.delete
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
public void move(java.lang.Object requestor, VirtualFile newParent)
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.move
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
newParent
- the directory to move this file topublic VirtualFile copy(java.lang.Object requestor, VirtualFile newParent, java.lang.String copyName)
copy
in class VirtualFile
protected void storeCharset(java.nio.charset.Charset charset)
storeCharset
in class VirtualFile
public void setCharset(java.nio.charset.Charset charset)
setCharset
in class VirtualFile
public void setCharset(java.nio.charset.Charset charset, java.lang.Runnable whenChanged)
setCharset
in class VirtualFile
public void setCharset(java.nio.charset.Charset charset, java.lang.Runnable whenChanged, boolean fireEventsWhenChanged)
setCharset
in class VirtualFile
public void setBinaryContent(byte [] content, long newModificationStamp, long newTimeStamp)
setBinaryContent
in class VirtualFile
public void setBinaryContent(byte [] content, long newModificationStamp, long newTimeStamp, java.lang.Object requestor)
setBinaryContent
in class VirtualFile
public void refresh(boolean asynchronous, boolean recursive)
VirtualFile
Refreshes the cached file information from the physical file system. If this file is not a directory
the timestamp value is refreshed and contentsChanged
event is fired if it is changed.
If this file is a directory the set of its children is refreshed. If recursive value is true
all
children are refreshed recursively.
When invoking synchronous refresh from a thread other than the event dispatch thread, the current thread must NOT be in a read action, otherwise a deadlock may occur.
refresh
in class VirtualFile
asynchronous
- if true
, the method will return immediately and the refresh will be processed
in the background. If false
, the method will return only after the refresh
is done and the VFS change events caused by the refresh have been fired and processed
in the event dispatch thread. Instead of synchronous refreshes, it's recommended to use
asynchronous refreshes with a postRunnable
whenever possible.recursive
- whether to refresh all the files in this directory recursivelypublic void setBOM(byte [] BOM)
setBOM
in class VirtualFile
public void setDetectedLineSeparator(java.lang.String separator)
setDetectedLineSeparator
in class VirtualFile
public void setPreloadedContentHint(byte[] preloadedContentHint)
setPreloadedContentHint
in class VirtualFile
public <T> void putUserData(Key<T> key, T value)
UserDataHolder
putUserData
in interface UserDataHolder
putUserData
in class UserDataHolderBase
public <T> void putCopyableUserData(Key<T> key, T value)
putCopyableUserData
in class UserDataHolderBase
public <T> boolean replace(Key<T> key, T oldValue, T newValue)
UserDataHolderEx
replace
in interface UserDataHolderEx
replace
in class UserDataHolderBase
ConcurrentMap.replace(Object, Object, Object)
public <T> T putUserDataIfAbsent(Key<T> key, T value)
putUserDataIfAbsent
in interface UserDataHolderEx
putUserDataIfAbsent
in class UserDataHolderBase
protected void clearUserData()
clearUserData
in class UserDataHolderBase
protected void setUserMap(KeyFMap map)
setUserMap
in class UserDataHolderBase