gs.hitchin.hitchfs
Class FakeFile

java.lang.Object
  extended by java.io.File
      extended by gs.hitchin.hitchfs.FakeFile
All Implemented Interfaces:
Serializable, Comparable<File>

public class FakeFile
extends File

A testing version of java.io.File. Each method is overridden to call back to a FakeFileOperations interface, allowing fine grained control of what files are allowed to do. The original java.io.File methods are still available to be called with the same method name with an underscore prepended. For example, a call of .exists() on FakeFile will call back to a provided FakeFileOperations implementation, where ._exists() will call the original File implementation.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
FakeFile(FakeFileOperations fs, File file)
          http://www.docjar.com/html/api/java/io/File.java.html
FakeFile(FakeFileOperations fs, File parent, String child)
          http://www.docjar.com/html/api/java/io/File.java.html
FakeFile(FakeFileOperations fs, String pathname)
          http://www.docjar.com/html/api/java/io/File.java.html
FakeFile(FakeFileOperations fs, String parent, String child)
          http://www.docjar.com/html/api/java/io/File.java.html
FakeFile(FakeFileOperations fs, URI uri)
          http://www.docjar.com/html/api/java/io/File.java.html
 
Method Summary
 boolean _canExecute()
           
 boolean _canRead()
           
 boolean _canWrite()
           
 int _compareTo(File pathname)
           
 boolean _createNewFile()
           
 boolean _delete()
           
 void _deleteOnExit()
           
 boolean _equals(Object obj)
           
 boolean _exists()
           
 File _getAbsoluteFile()
           
 String _getAbsolutePath()
           
 File _getCanonicalFile()
           
 String _getCanonicalPath()
           
 long _getFreeSpace()
           
 String _getName()
           
 String _getParent()
           
 File _getParentFile()
           
 String _getPath()
           
 long _getTotalSpace()
           
 long _getUsableSpace()
           
 int _hashCode()
           
 boolean _isAbsolute()
           
 boolean _isDirectory()
           
 boolean _isFile()
           
 boolean _isHidden()
           
 long _lastModified()
           
 long _length()
           
 String[] _list()
           
 String[] _list(FilenameFilter filter)
           
 File[] _listFiles()
           
 File[] _listFiles(FileFilter filter)
           
 File[] _listFiles(FilenameFilter filter)
           
 boolean _mkdir()
           
 boolean _mkdirs()
           
 boolean _renameTo(File dest)
           
 boolean _setExecutable(boolean executable)
           
 boolean _setExecutable(boolean executable, boolean ownerOnly)
           
 boolean _setLastModified(long time)
           
 boolean _setReadable(boolean readable)
           
 boolean _setReadable(boolean readable, boolean ownerOnly)
           
 boolean _setReadOnly()
           
 boolean _setWritable(boolean writable)
           
 boolean _setWritable(boolean writable, boolean ownerOnly)
           
 String _toString()
           
 URI _toURI()
           
 boolean canExecute()
           
 boolean canRead()
           
 boolean canWrite()
           
 int compareTo(File pathname)
           
 boolean createNewFile()
           
 boolean delete()
           
 void deleteOnExit()
           
 boolean equals(Object obj)
           
 boolean exists()
           
 File getAbsoluteFile()
           
 String getAbsolutePath()
           
 File getCanonicalFile()
           
 String getCanonicalPath()
           
 long getFreeSpace()
           
 String getKey()
           
 String getName()
           
 String getParent()
           
 File getParentFile()
           
 String getPath()
           
 String getPathField()
           
static String getPathField(File file)
           
static int getPrefixLength(File file)
           
 int getPrefixLengthField()
           
 PropStore getProperties()
           
<T extends FileProp>
T
getProperty(Class<T> prop)
           
 long getTotalSpace()
           
 long getUsableSpace()
           
 int hashCode()
           
 boolean hasProperty(Class<?> type)
           
 boolean isAbsolute()
           
 boolean isDirectory()
           
 boolean isFile()
           
 boolean isHidden()
           
 long lastModified()
           
 long length()
           
 String[] list()
           
 String[] list(FilenameFilter filter)
           
 File[] listFiles()
           
 File[] listFiles(FileFilter filter)
           
 File[] listFiles(FilenameFilter filter)
           
 boolean mkdir()
           
 boolean mkdirs()
           
 boolean renameTo(File dest)
           
 boolean setExecutable(boolean executable)
           
 boolean setExecutable(boolean executable, boolean ownerOnly)
           
 void setHidden(boolean hidden)
           
 FakeFile setKey(String key)
           
 boolean setLastModified(long time)
           
 FakeFile setPathField(String path)
           
 FakeFile setPrefixLengthField(int prefixLength)
           
 void setProperties(PropStore props)
           
 boolean setReadable(boolean readable)
           
 boolean setReadable(boolean readable, boolean ownerOnly)
           
 boolean setReadOnly()
           
 boolean setWritable(boolean writable)
           
 boolean setWritable(boolean writable, boolean ownerOnly)
           
 String toString()
           
 void touch()
           
 URI toURI()
           
<P extends FileProp,S>
S
visitProperty(Class<P> type, PropStore.PropVisitor<P,S> visitor)
           
<T extends FileProp>
FakeFile
withProperty(Class<T> type, T value)
           
 FakeFile withProperty(FileProp property)
           
 
Methods inherited from class java.io.File
createTempFile, createTempFile, listRoots, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FakeFile

public FakeFile(FakeFileOperations fs,
                File file)
http://www.docjar.com/html/api/java/io/File.java.html


FakeFile

public FakeFile(FakeFileOperations fs,
                File parent,
                String child)
http://www.docjar.com/html/api/java/io/File.java.html


FakeFile

public FakeFile(FakeFileOperations fs,
                String pathname)
http://www.docjar.com/html/api/java/io/File.java.html


FakeFile

public FakeFile(FakeFileOperations fs,
                String parent,
                String child)
http://www.docjar.com/html/api/java/io/File.java.html


FakeFile

public FakeFile(FakeFileOperations fs,
                URI uri)
http://www.docjar.com/html/api/java/io/File.java.html

Method Detail

_canExecute

public boolean _canExecute()

_canRead

public boolean _canRead()

_canWrite

public boolean _canWrite()

_compareTo

public int _compareTo(File pathname)

_createNewFile

public boolean _createNewFile()
                       throws IOException
Throws:
IOException

_delete

public boolean _delete()

_deleteOnExit

public void _deleteOnExit()

_equals

public boolean _equals(Object obj)

_exists

public boolean _exists()

_getAbsoluteFile

public File _getAbsoluteFile()

_getAbsolutePath

public String _getAbsolutePath()

_getCanonicalFile

public File _getCanonicalFile()
                       throws IOException
Throws:
IOException

_getCanonicalPath

public String _getCanonicalPath()
                         throws IOException
Throws:
IOException

_getFreeSpace

public long _getFreeSpace()

_getName

public String _getName()

_getParent

public String _getParent()

_getParentFile

public File _getParentFile()

_getPath

public String _getPath()

_getTotalSpace

public long _getTotalSpace()

_getUsableSpace

public long _getUsableSpace()

_hashCode

public int _hashCode()

_isAbsolute

public boolean _isAbsolute()

_isDirectory

public boolean _isDirectory()

_isFile

public boolean _isFile()

_isHidden

public boolean _isHidden()

_lastModified

public long _lastModified()

_length

public long _length()

_list

public String[] _list()

_list

public String[] _list(FilenameFilter filter)

_listFiles

public File[] _listFiles()

_listFiles

public File[] _listFiles(FileFilter filter)

_listFiles

public File[] _listFiles(FilenameFilter filter)

_mkdir

public boolean _mkdir()

_mkdirs

public boolean _mkdirs()

_renameTo

public boolean _renameTo(File dest)

_setExecutable

public boolean _setExecutable(boolean executable)

_setExecutable

public boolean _setExecutable(boolean executable,
                              boolean ownerOnly)

_setLastModified

public boolean _setLastModified(long time)

_setReadable

public boolean _setReadable(boolean readable)

_setReadable

public boolean _setReadable(boolean readable,
                            boolean ownerOnly)

_setReadOnly

public boolean _setReadOnly()

_setWritable

public boolean _setWritable(boolean writable)

_setWritable

public boolean _setWritable(boolean writable,
                            boolean ownerOnly)

_toString

public String _toString()

_toURI

public URI _toURI()

canExecute

public boolean canExecute()
Overrides:
canExecute in class File

canRead

public boolean canRead()
Overrides:
canRead in class File

canWrite

public boolean canWrite()
Overrides:
canWrite in class File

compareTo

public int compareTo(File pathname)
Specified by:
compareTo in interface Comparable<File>
Overrides:
compareTo in class File

createNewFile

public boolean createNewFile()
                      throws IOException
Overrides:
createNewFile in class File
Throws:
IOException

delete

public boolean delete()
Overrides:
delete in class File

deleteOnExit

public void deleteOnExit()
Overrides:
deleteOnExit in class File

equals

public boolean equals(Object obj)
Overrides:
equals in class File

exists

public boolean exists()
Overrides:
exists in class File

getAbsoluteFile

public File getAbsoluteFile()
Overrides:
getAbsoluteFile in class File

getAbsolutePath

public String getAbsolutePath()
Overrides:
getAbsolutePath in class File

getCanonicalFile

public File getCanonicalFile()
                      throws IOException
Overrides:
getCanonicalFile in class File
Throws:
IOException

getCanonicalPath

public String getCanonicalPath()
                        throws IOException
Overrides:
getCanonicalPath in class File
Throws:
IOException

getFreeSpace

public long getFreeSpace()
Overrides:
getFreeSpace in class File

getKey

public String getKey()

getName

public String getName()
Overrides:
getName in class File

getParent

public String getParent()
Overrides:
getParent in class File

getParentFile

public File getParentFile()
Overrides:
getParentFile in class File

getPath

public String getPath()
Overrides:
getPath in class File

getPathField

public String getPathField()

getPathField

public static String getPathField(File file)

getPrefixLength

public static int getPrefixLength(File file)

getPrefixLengthField

public int getPrefixLengthField()

getProperties

public PropStore getProperties()

getProperty

public <T extends FileProp> T getProperty(Class<T> prop)

getTotalSpace

public long getTotalSpace()
Overrides:
getTotalSpace in class File

getUsableSpace

public long getUsableSpace()
Overrides:
getUsableSpace in class File

hashCode

public int hashCode()
Overrides:
hashCode in class File

hasProperty

public boolean hasProperty(Class<?> type)

isAbsolute

public boolean isAbsolute()
Overrides:
isAbsolute in class File

isDirectory

public boolean isDirectory()
Overrides:
isDirectory in class File

isFile

public boolean isFile()
Overrides:
isFile in class File

isHidden

public boolean isHidden()
Overrides:
isHidden in class File

lastModified

public long lastModified()
Overrides:
lastModified in class File

length

public long length()
Overrides:
length in class File

list

public String[] list()
Overrides:
list in class File

list

public String[] list(FilenameFilter filter)
Overrides:
list in class File

listFiles

public File[] listFiles()
Overrides:
listFiles in class File

listFiles

public File[] listFiles(FileFilter filter)
Overrides:
listFiles in class File

listFiles

public File[] listFiles(FilenameFilter filter)
Overrides:
listFiles in class File

mkdir

public boolean mkdir()
Overrides:
mkdir in class File

mkdirs

public boolean mkdirs()
Overrides:
mkdirs in class File

renameTo

public boolean renameTo(File dest)
Overrides:
renameTo in class File

setExecutable

public boolean setExecutable(boolean executable)
Overrides:
setExecutable in class File

setExecutable

public boolean setExecutable(boolean executable,
                             boolean ownerOnly)
Overrides:
setExecutable in class File

setHidden

public void setHidden(boolean hidden)

setKey

public FakeFile setKey(String key)

setLastModified

public boolean setLastModified(long time)
Overrides:
setLastModified in class File

setPathField

public FakeFile setPathField(String path)

setPrefixLengthField

public FakeFile setPrefixLengthField(int prefixLength)

setProperties

public void setProperties(PropStore props)

setReadable

public boolean setReadable(boolean readable)
Overrides:
setReadable in class File

setReadable

public boolean setReadable(boolean readable,
                           boolean ownerOnly)
Overrides:
setReadable in class File

setReadOnly

public boolean setReadOnly()
Overrides:
setReadOnly in class File

setWritable

public boolean setWritable(boolean writable)
Overrides:
setWritable in class File

setWritable

public boolean setWritable(boolean writable,
                           boolean ownerOnly)
Overrides:
setWritable in class File

toString

public String toString()
Overrides:
toString in class File

touch

public void touch()

toURI

public URI toURI()
Overrides:
toURI in class File

visitProperty

public <P extends FileProp,S> S visitProperty(Class<P> type,
                                              PropStore.PropVisitor<P,S> visitor)

withProperty

public <T extends FileProp> FakeFile withProperty(Class<T> type,
                                                  T value)

withProperty

public FakeFile withProperty(FileProp property)


Copyright © 2012. All Rights Reserved.