|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.intellij.openapi.vfs.VirtualFile
public abstract class VirtualFile
Represents a file in .
VirtualFileSystem
VirtualFileSystem,
VirtualFileManager| Field Summary | |
|---|---|
static VirtualFile[] |
EMPTY_ARRAY
|
protected byte[] |
myBOM
|
static java.lang.String |
PROP_NAME
Used as a property name in the VirtualFilePropertyEvent fired when the name of a
VirtualFile changes. |
static java.lang.String |
PROP_WRITABLE
Used as a property name in the VirtualFilePropertyEvent fired when the write permission of a
VirtualFile changes. |
| Fields inherited from interface com.intellij.openapi.util.ModificationTracker |
|---|
EVER_CHANGED |
| Constructor Summary | |
|---|---|
protected |
VirtualFile()
|
| Method Summary | ||
|---|---|---|
abstract byte[] |
contentsToByteArray()
Returns file content as an array of bytes. |
|
abstract char[] |
contentsToCharArray()
Returns file content as an array of characters. |
|
abstract VirtualFile |
createChildData(java.lang.Object requestor,
java.lang.String name)
Creates a new file in this directory. |
|
abstract VirtualFile |
createChildDirectory(java.lang.Object requestor,
java.lang.String name)
Creates a subdirectory in this directory. |
|
abstract void |
delete(java.lang.Object requestor)
Deletes this file. |
|
VirtualFile |
findChild(java.lang.String name)
Finds child of this file with the given name. |
|
VirtualFile |
findFileByRelativePath(java.lang.String relPath)
Finds file by path relative to this file. |
|
abstract long |
getActualTimeStamp()
Gets the file timestamp. |
|
java.nio.charset.Charset |
getCharset()
|
|
abstract VirtualFile[] |
getChildren()
Gets the child files. |
|
java.lang.String |
getExtension()
Gets the extension of this file. |
|
abstract VirtualFileSystem |
getFileSystem()
Gets the VirtualFileSystem this file belongs to. |
|
FileType |
getFileType()
|
|
javax.swing.Icon |
getIcon()
|
|
abstract java.io.InputStream |
getInputStream()
Gets the InputStream for this file. |
|
abstract long |
getLength()
File length in bytes. |
|
long |
getModificationCount()
|
|
abstract long |
getModificationStamp()
Gets modification stamp value. |
|
abstract java.lang.String |
getName()
Gets the name of this file. |
|
java.lang.String |
getNameWithoutExtension()
Gets the file name without the extension. |
|
java.io.OutputStream |
getOutputStream(java.lang.Object requestor)
Gets the OutputStream for this file. |
|
abstract 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. |
|
abstract VirtualFile |
getParent()
Gets the parent VirtualFile. |
|
abstract java.lang.String |
getPath()
Gets the path of this file. |
|
java.lang.String |
getPresentableName()
|
|
java.lang.String |
getPresentableUrl()
Fetches "presentable URL" of this file. |
|
java.io.Reader |
getReader()
Gets the Reader for this file. |
|
static java.io.Reader |
getReader(byte[] bytes)
|
|
abstract long |
getTimeStamp()
Gets the timestamp for this file. |
|
java.lang.String |
getUrl()
Gets the URL of this file. |
|
|
getUserData(Key<T> key)
|
|
java.io.Writer |
getWriter(java.lang.Object requestor)
Gets the Writer for this file. |
|
java.io.Writer |
getWriter(java.lang.Object requestor,
long newModificationStamp,
long newTimeStamp)
Gets the Writer for this file and sets modification stamp and time stamp to the specified values
after closing the Writer. |
|
abstract boolean |
isDirectory()
Checks whether this file is a directory. |
|
abstract boolean |
isValid()
Checks whether this VirtualFile is valid. |
|
abstract boolean |
isWritable()
Checks whether this file has write permission. |
|
abstract void |
move(java.lang.Object requestor,
VirtualFile newParent)
Moves this file to another directory. |
|
boolean |
nameEquals(java.lang.String name)
|
|
byte[] |
physicalContentsToByteArray()
|
|
|
putUserData(Key<T> key,
T value)
|
|
void |
refresh(boolean asynchronous,
boolean recursive)
Refreshes the cached file information from the physical file system. |
|
abstract void |
refresh(boolean asynchronous,
boolean recursive,
java.lang.Runnable postRunnable)
The same as refresh(boolean asynchronous, boolean recursive) but also runs postRunnable
after the operation is completed. |
|
abstract void |
rename(java.lang.Object requestor,
java.lang.String newName)
Renames this file to the newName. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final VirtualFile[] EMPTY_ARRAY
protected byte[] myBOM
public static final java.lang.String PROP_NAME
VirtualFilePropertyEvent fired when the name of a
VirtualFile changes.
VirtualFileListener.propertyChanged(com.intellij.openapi.vfs.VirtualFilePropertyEvent),
VirtualFilePropertyEvent.getPropertyName(),
Constant Field Valuespublic static final java.lang.String PROP_WRITABLE
VirtualFilePropertyEvent fired when the write permission of a
VirtualFile changes.
VirtualFileListener.propertyChanged(com.intellij.openapi.vfs.VirtualFilePropertyEvent),
VirtualFilePropertyEvent.getPropertyName(),
Constant Field Values| Constructor Detail |
|---|
protected VirtualFile()
| Method Detail |
|---|
@NotNull public abstract VirtualFileSystem getFileSystem()
VirtualFileSystem this file belongs to.
VirtualFileSystempublic abstract java.lang.String getPath()
VirtualFileSystem. Format of the path depends on the concrete file system.
For LocalFileSystem it is an absoulute file path with file separator characters
(File.separatorChar) replaced to the forward slash ('/').
@NotNull public java.lang.String getUrl()
<protocol>://<path>.
File can be found by its URL using VirtualFileManager.findFileByUrl(java.lang.String) method.
VirtualFileManager.findFileByUrl(java.lang.String),
getPath(),
VirtualFileSystem.getProtocol()public final java.lang.String getPresentableUrl()
VirtualFileSystem.extractPresentableUrl(java.lang.String)@NotNull public abstract java.lang.String getName()
@Nullable public java.lang.String getExtension()
@NotNull public java.lang.String getNameWithoutExtension()
getName() method returns is returned.
public abstract void rename(java.lang.Object requestor,
java.lang.String newName)
throws java.io.IOException
newName.
This method should be only called within write-action.
See Application.runWriteAction(java.lang.Runnable).
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()newName - the new file name
java.io.IOException - if file failed to be renamedpublic abstract boolean isWritable()
true if this file is writable, false otherwisepublic abstract boolean isDirectory()
true if this file is a directory, fasle otherwisepublic abstract boolean isValid()
VirtualFile is valid. File can be invalidated either by deleting it or one of its
parents with delete(java.lang.Object) method or by an external change.
If file is not valid only Object.equals(java.lang.Object), Object.hashCode() and methods from
UserDataHolder can be called for it. Using any other methods for an invalid VirtualFile instance
produce inpredictable results.
true if this is a valid file, fasle otherwise@Nullable public abstract VirtualFile getParent()
VirtualFile.
null if this file is a root directorypublic abstract VirtualFile[] getChildren()
null if this file is not a directorypublic VirtualFile findChild(java.lang.String name)
name - the file name to search by
null otherwisepublic javax.swing.Icon getIcon()
public FileType getFileType()
@Nullable public VirtualFile findFileByRelativePath(java.lang.String relPath)
relPath - the relative path to search by
null otherwise
public abstract VirtualFile createChildDirectory(java.lang.Object requestor,
java.lang.String name)
throws java.io.IOException
Application.runWriteAction(java.lang.Runnable).
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 name
VirtualFile representing the created directory
java.io.IOException - if directory failed to be created
public abstract VirtualFile createChildData(java.lang.Object requestor,
java.lang.String name)
throws java.io.IOException
Application.runWriteAction(java.lang.Runnable).
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 file
java.io.IOException - if file failed to be created
public abstract void delete(java.lang.Object requestor)
throws java.io.IOException
Application.runWriteAction(java.lang.Runnable).
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()
java.io.IOException - if file failed to be deleted
public abstract void move(java.lang.Object requestor,
VirtualFile newParent)
throws java.io.IOException
Application.runWriteAction(java.lang.Runnable).
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 to
java.io.IOException - if file failed to be moved
public abstract java.io.InputStream getInputStream()
throws java.io.IOException
InputStream for this file.
InputStream
java.io.IOException - if an I/O error occurscontentsToByteArray()
public final java.io.OutputStream getOutputStream(java.lang.Object requestor)
throws java.io.IOException
OutputStream for this file.
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()
OutputStream
java.io.IOException - if an I/O error occurs
public abstract java.io.OutputStream getOutputStream(java.lang.Object requestor,
long newModificationStamp,
long newTimeStamp)
throws java.io.IOException
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.
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()newModificationStamp - new modification stamp or -1 if no special value should be setnewTimeStamp - new time stamp or -1 if no special value should be set
OutputStream
java.io.IOException - if an I/O error occursgetOutputStream(Object),
getModificationStamp()public java.nio.charset.Charset getCharset()
public java.io.Reader getReader()
throws java.io.IOException
Reader for this file.
Reader
java.io.IOException - if an I/O error occurscontentsToCharArray()
public static java.io.Reader getReader(byte[] bytes)
throws java.io.IOException
java.io.IOException
public final java.io.Writer getWriter(java.lang.Object requestor)
throws java.io.IOException
Writer for this file.
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()
Writer
java.io.IOException - if an I/O error occurs
public java.io.Writer getWriter(java.lang.Object requestor,
long newModificationStamp,
long newTimeStamp)
throws java.io.IOException
Writer for this file and sets modification stamp and time stamp to the specified values
after closing the Writer.Normally you should not use this method.
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()newModificationStamp - new modification stamp or -1 if no special value should be setnewTimeStamp - new time stamp or -1 if no special value should be set
Writer
java.io.IOException - if an I/O error occursgetWriter(Object),
getModificationStamp()
public abstract byte[] contentsToByteArray()
throws java.io.IOException
java.io.IOException - if an I/O error occursgetInputStream()
public abstract char[] contentsToCharArray()
throws java.io.IOException
java.io.IOException - if an I/O error occursgetReader()public abstract long getModificationStamp()
getTimeStamp()public abstract long getTimeStamp()
getActualTimeStamp(),
File.lastModified()public abstract long getActualTimeStamp()
getTimeStamp() returns the actual timestamp for this file.
getTimeStamp()public abstract long getLength()
public void refresh(boolean asynchronous,
boolean recursive)
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.
This method should be only called within write-action.
See Application.runWriteAction(java.lang.Runnable).
asynchronous - if true then the operation will be performed in a separate thread,
otherwise will be performed immediatelyrecursive - whether to refresh all the files in this directory recursively
public abstract void refresh(boolean asynchronous,
boolean recursive,
java.lang.Runnable postRunnable)
refresh(boolean asynchronous, boolean recursive) but also runs postRunnable
after the operation is completed.
public <T> T getUserData(Key<T> key)
getUserData in interface UserDataHolder
public <T> void putUserData(Key<T> key,
T value)
putUserData in interface UserDataHolder
public byte[] physicalContentsToByteArray()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getPresentableName()
public long getModificationCount()
getModificationCount in interface ModificationTrackerpublic boolean nameEquals(java.lang.String name)
name -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||