com.aptana.ide.core.io
Class VirtualFile

java.lang.Object
  extended by com.aptana.ide.core.io.VirtualFile
All Implemented Interfaces:
IVirtualFile, java.lang.Comparable
Direct Known Subclasses:
FtpVirtualFile, LocalFile

public abstract class VirtualFile
extends java.lang.Object
implements IVirtualFile

Base implementation of IVirtualFile

Author:
Ingo Muschenetz

Constructor Summary
VirtualFile()
           
 
Method Summary
abstract  boolean canRead()
          Determine if this virtual file is readable given the current set of permissions
abstract  boolean canWrite()
          Determine if this virtual file is writable given the current set of permissions
abstract  boolean delete()
          Remove this virtual file from the file manager
abstract  boolean exists()
          Determine if this virtual file exists in it's file system
abstract  java.lang.String getAbsolutePath()
          Get the path, filename and extension of this virtual file
abstract  long getCreationMillis()
          Get the creation time of this file in milliseconds
abstract  java.lang.String getExtension()
          Get the extension for this virtual file
abstract  IVirtualFileManager getFileManager()
          Get the file manager that this file belongs to
 IVirtualFile[] getFiles()
          Retrieve a list of files contained by this virtual file
abstract  IVirtualFile[] getFiles(boolean recurse, boolean includeCloakedFiles)
          Retrieve a list of files contained by this virtual file
abstract  java.lang.String getGroup()
          Get the group to which this file belongs
abstract  org.eclipse.swt.graphics.Image getImage()
          getImage
abstract  long getModificationMillis()
          Get the modification time of this file in milliseconds
abstract  java.lang.String getName()
          Get the filename and extension of this virtual file.
abstract  java.lang.String getOwner()
          Get the owner of this file
static IVirtualFile[] getParentDirectories(IVirtualFile file, IVirtualFileManager sourceManager)
          Creates a list of all parent directories of the current file (or directory)
abstract  IVirtualFile getParentFile()
          Retrieve the virtual file that contains file file
abstract  java.lang.String getPath()
          Doesn't include filename and extension.
abstract  long getPermissions()
          Get the file permissions for this file
abstract  java.lang.String getRelativePath()
          Returns a path relative to the parent virtual file manager
abstract  long getSize()
          getSize
abstract  java.io.InputStream getStream()
          Get an input stream for the contents of this virtual file
 java.lang.String getTimeStamp()
          Gets the raw time stamp for the file
abstract  boolean hasFiles()
          Determines if this virtual file contains files
abstract  boolean isDirectory()
          Determines if this virtual file represents a directory
abstract  boolean isFile()
          Determines if this virtual file represents a file
 boolean isLocal()
          Is this file local?
abstract  void putStream(java.io.InputStream input)
          Put the content of the specified input stream into this virtual file.
static IVirtualFile[] removeDuplicateFile(IVirtualFile[] files, IVirtualFile toRemove)
          Remove a duplicate file from the list of files
abstract  boolean rename(java.lang.String newName)
          Rename this file
static IVirtualFile[] reparentFiles(IVirtualFileManager manager, IVirtualFile[] files)
          Deprecated.  
abstract  void setGroup(java.lang.String group)
          Change this file's group name
abstract  void setImage(org.eclipse.swt.graphics.Image image)
          setImage
abstract  void setModificationMillis(long modificationTime)
          Sets the modification time of this file in milliseconds
abstract  void setOwner(java.lang.String owner)
          Change this file's owner
abstract  void setPermissions(long permissions)
          Set the file permissions on this file
 void setTimeStamp(java.lang.String timeStamp)
          Sets the raw time stamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.aptana.ide.core.io.IVirtualFile
editProperties, isCloaked, setCloaked
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

VirtualFile

public VirtualFile()
Method Detail

getCreationMillis

public abstract long getCreationMillis()
Description copied from interface: IVirtualFile
Get the creation time of this file in milliseconds

Specified by:
getCreationMillis in interface IVirtualFile
Returns:
long
See Also:
IVirtualFile.getCreationMillis()

isDirectory

public abstract boolean isDirectory()
Description copied from interface: IVirtualFile
Determines if this virtual file represents a directory

Specified by:
isDirectory in interface IVirtualFile
Returns:
Returns true if this virtual file is a directory
See Also:
IVirtualFile.isDirectory()

isFile

public abstract boolean isFile()
Description copied from interface: IVirtualFile
Determines if this virtual file represents a file

Specified by:
isFile in interface IVirtualFile
Returns:
Returns true if this virtual file is a file
See Also:
IVirtualFile.isFile()

isLocal

public boolean isLocal()
Description copied from interface: IVirtualFile
Is this file local?

Specified by:
isLocal in interface IVirtualFile
Returns:
boolean
See Also:
IVirtualFile.isLocal()

getExtension

public abstract java.lang.String getExtension()
Description copied from interface: IVirtualFile
Get the extension for this virtual file

Specified by:
getExtension in interface IVirtualFile
Returns:
Returns the file extension including the leading '.'
See Also:
IVirtualFile.getExtension()

getFiles

public IVirtualFile[] getFiles()
                        throws ConnectionException,
                               java.io.IOException
Description copied from interface: IVirtualFile
Retrieve a list of files contained by this virtual file

Specified by:
getFiles in interface IVirtualFile
Returns:
Returns an array of virtual files. This will return an empty array if this virtual file contains no other files
Throws:
ConnectionException
java.io.IOException
See Also:
IVirtualFile.getFiles()

getFiles

public abstract IVirtualFile[] getFiles(boolean recurse,
                                        boolean includeCloakedFiles)
                                 throws ConnectionException,
                                        java.io.IOException
Description copied from interface: IVirtualFile
Retrieve a list of files contained by this virtual file

Specified by:
getFiles in interface IVirtualFile
Parameters:
recurse -
includeCloakedFiles -
Returns:
IVirtualFile[]
Throws:
ConnectionException
java.io.IOException
See Also:
IVirtualFile.getFiles()

hasFiles

public abstract boolean hasFiles()
Description copied from interface: IVirtualFile
Determines if this virtual file contains files

Specified by:
hasFiles in interface IVirtualFile
Returns:
Returns true if this virtual file is a directory containing other files
See Also:
IVirtualFile.hasFiles()

getAbsolutePath

public abstract java.lang.String getAbsolutePath()
Description copied from interface: IVirtualFile
Get the path, filename and extension of this virtual file

Specified by:
getAbsolutePath in interface IVirtualFile
Returns:
Returns the full path, name, and extension for this file
See Also:
IVirtualFile.getAbsolutePath()

getFileManager

public abstract IVirtualFileManager getFileManager()
Description copied from interface: IVirtualFile
Get the file manager that this file belongs to

Specified by:
getFileManager in interface IVirtualFile
Returns:
Returns this file's owning file manager
See Also:
IVirtualFile.getFileManager()

getGroup

public abstract java.lang.String getGroup()
Description copied from interface: IVirtualFile
Get the group to which this file belongs

Specified by:
getGroup in interface IVirtualFile
Returns:
This file's group name
See Also:
IVirtualFile.getGroup()

setGroup

public abstract void setGroup(java.lang.String group)
Description copied from interface: IVirtualFile
Change this file's group name

Specified by:
setGroup in interface IVirtualFile
See Also:
IVirtualFile.setGroup(String)

getImage

public abstract org.eclipse.swt.graphics.Image getImage()
Description copied from interface: IVirtualFile
getImage

Specified by:
getImage in interface IVirtualFile
Returns:
Image
See Also:
IVirtualFile.getImage()

setImage

public abstract void setImage(org.eclipse.swt.graphics.Image image)
Description copied from interface: IVirtualFile
setImage

Specified by:
setImage in interface IVirtualFile
See Also:
IVirtualFile.setImage(Image)

getModificationMillis

public abstract long getModificationMillis()
Description copied from interface: IVirtualFile
Get the modification time of this file in milliseconds

Specified by:
getModificationMillis in interface IVirtualFile
Returns:
long
See Also:
IVirtualFile.getModificationMillis()

setModificationMillis

public abstract void setModificationMillis(long modificationTime)
                                    throws java.io.IOException,
                                           ConnectionException
Description copied from interface: IVirtualFile
Sets the modification time of this file in milliseconds

Specified by:
setModificationMillis in interface IVirtualFile
Throws:
java.io.IOException
ConnectionException
See Also:
IVirtualFile.setModificationMillis(long)

getName

public abstract java.lang.String getName()
Description copied from interface: IVirtualFile
Get the filename and extension of this virtual file. This should exclude the parent directory of the file

Specified by:
getName in interface IVirtualFile
Returns:
Returns this virtual file's name and extension
See Also:
IVirtualFile.getName()

getOwner

public abstract java.lang.String getOwner()
Description copied from interface: IVirtualFile
Get the owner of this file

Specified by:
getOwner in interface IVirtualFile
Returns:
This file's group name
See Also:
IVirtualFile.getOwner()

setOwner

public abstract void setOwner(java.lang.String owner)
Description copied from interface: IVirtualFile
Change this file's owner

Specified by:
setOwner in interface IVirtualFile
See Also:
IVirtualFile.setOwner(String)

getParentFile

public abstract IVirtualFile getParentFile()
Description copied from interface: IVirtualFile
Retrieve the virtual file that contains file file

Specified by:
getParentFile in interface IVirtualFile
Returns:
Returns this file's parent file
See Also:
IVirtualFile.getParentFile()

getPath

public abstract java.lang.String getPath()
Description copied from interface: IVirtualFile
Doesn't include filename and extension. Includes trailing file separator

Specified by:
getPath in interface IVirtualFile
Returns:
Returns the path to this virtual file
See Also:
IVirtualFile.getPath()

setPermissions

public abstract void setPermissions(long permissions)
Description copied from interface: IVirtualFile
Set the file permissions on this file

Specified by:
setPermissions in interface IVirtualFile
Parameters:
permissions - The new file permission settings
See Also:
IVirtualFile.setPermissions(long)

getPermissions

public abstract long getPermissions()
Description copied from interface: IVirtualFile
Get the file permissions for this file

Specified by:
getPermissions in interface IVirtualFile
Returns:
Returns the file permissions settings for this file
See Also:
IVirtualFile.getPermissions()

getSize

public abstract long getSize()
Description copied from interface: IVirtualFile
getSize

Specified by:
getSize in interface IVirtualFile
Returns:
long
See Also:
IVirtualFile.getSize()

getStream

public abstract java.io.InputStream getStream()
                                       throws ConnectionException,
                                              VirtualFileManagerException
Description copied from interface: IVirtualFile
Get an input stream for the contents of this virtual file

Specified by:
getStream in interface IVirtualFile
Returns:
Returns an InputStream of null
Throws:
ConnectionException
VirtualFileManagerException
See Also:
IVirtualFile.getStream()

putStream

public abstract void putStream(java.io.InputStream input)
                        throws ConnectionException,
                               VirtualFileManagerException,
                               java.io.IOException
Description copied from interface: IVirtualFile
Put the content of the specified input stream into this virtual file. This will create a new file if it does not already exist. This will replace the entire content of the file if it does exist

Specified by:
putStream in interface IVirtualFile
Parameters:
input - The input stream from which to retrieve data to place into this virtual file
Throws:
java.io.IOException
ConnectionException
VirtualFileManagerException
See Also:
IVirtualFile.putStream(java.io.InputStream)

canRead

public abstract boolean canRead()
Description copied from interface: IVirtualFile
Determine if this virtual file is readable given the current set of permissions

Specified by:
canRead in interface IVirtualFile
Returns:
Returns true if this virtual file is readable
See Also:
IVirtualFile.canRead()

canWrite

public abstract boolean canWrite()
Description copied from interface: IVirtualFile
Determine if this virtual file is writable given the current set of permissions

Specified by:
canWrite in interface IVirtualFile
Returns:
Returns true if this virtual file is writable
See Also:
IVirtualFile.canWrite()

delete

public abstract boolean delete()
                        throws ConnectionException,
                               VirtualFileManagerException
Description copied from interface: IVirtualFile
Remove this virtual file from the file manager

Specified by:
delete in interface IVirtualFile
Returns:
Returns true if the file was successfully deleted
Throws:
ConnectionException
VirtualFileManagerException
See Also:
IVirtualFile.delete()

exists

public abstract boolean exists()
                        throws ConnectionException
Description copied from interface: IVirtualFile
Determine if this virtual file exists in it's file system

Specified by:
exists in interface IVirtualFile
Returns:
Returns true if the file exists
Throws:
ConnectionException
See Also:
IVirtualFile.exists()

rename

public abstract boolean rename(java.lang.String newName)
                        throws ConnectionException,
                               VirtualFileManagerException
Description copied from interface: IVirtualFile
Rename this file

Specified by:
rename in interface IVirtualFile
Parameters:
newName - The new name for this file
Returns:
Returns true if the rename was successful
Throws:
ConnectionException
VirtualFileManagerException
See Also:
IVirtualFile.rename(String)

getTimeStamp

public java.lang.String getTimeStamp()
Description copied from interface: IVirtualFile
Gets the raw time stamp for the file

Specified by:
getTimeStamp in interface IVirtualFile
Returns:
- time string
See Also:
IVirtualFile.getTimeStamp()

setTimeStamp

public void setTimeStamp(java.lang.String timeStamp)
Description copied from interface: IVirtualFile
Sets the raw time stamp

Specified by:
setTimeStamp in interface IVirtualFile
See Also:
IVirtualFile.setTimeStamp(java.lang.String)

getRelativePath

public abstract java.lang.String getRelativePath()
Description copied from interface: IVirtualFile
Returns a path relative to the parent virtual file manager

Specified by:
getRelativePath in interface IVirtualFile
Returns:
A relative path, or "/" if it is the root.
See Also:
IVirtualFile.getRelativePath()

removeDuplicateFile

public static IVirtualFile[] removeDuplicateFile(IVirtualFile[] files,
                                                 IVirtualFile toRemove)
Remove a duplicate file from the list of files

Parameters:
files - list of original files
toRemove - file to remove
Returns:
the list of files, filtered

reparentFiles

public static IVirtualFile[] reparentFiles(IVirtualFileManager manager,
                                           IVirtualFile[] files)
Deprecated. 

Re-parents this list of files under the new manager. This function should be replaced by an "import" function

Parameters:
manager -
files -
Returns:
IVirtualFile[]

getParentDirectories

public static IVirtualFile[] getParentDirectories(IVirtualFile file,
                                                  IVirtualFileManager sourceManager)
Creates a list of all parent directories of the current file (or directory)

Parameters:
file -
sourceManager -
Returns:
IVirtualFile[]