org.mockftpserver.fake.filesystem
Class FileEntry

java.lang.Object
  extended by org.mockftpserver.fake.filesystem.AbstractFileSystemEntry
      extended by org.mockftpserver.fake.filesystem.FileEntry
All Implemented Interfaces:
FileSystemEntry

public class FileEntry
extends AbstractFileSystemEntry

File system entry representing a file

Version:
$Revision: 219 $ - $Date: 2009-02-07 21:58:49 -0500 (Sat, 07 Feb 2009) $
Author:
Chris Mair

Constructor Summary
FileEntry()
          Construct a new instance without setting its path
FileEntry(String path)
          Construct a new instance with the specified value for its path
FileEntry(String path, String contents)
          Construct a new instance with the specified path and file contents
 
Method Summary
 FileSystemEntry cloneWithNewPath(String path)
          Return a new FileSystemEntry that is a clone of this object, except having the specified path
 InputStream createInputStream()
          Create and return an InputStream for reading the contents of the file represented by this entry
 OutputStream createOutputStream(boolean append)
          Create and return an OutputStream for writing the contents of the file represented by this entry
 long getSize()
          Return the size of this file
 boolean isDirectory()
          Return false to indicate that this entry represents a file
 void setContents(byte[] contents)
          Set the contents of the file represented by this entry
 void setContents(String contents)
          Set the contents of the file represented by this entry
 String toString()
           
 
Methods inherited from class org.mockftpserver.fake.filesystem.AbstractFileSystemEntry
getGroup, getLastModified, getName, getOwner, getPath, getPermissions, lockPath, setGroup, setLastModified, setOwner, setPath, setPermissions, setPermissionsFromString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileEntry

public FileEntry()
Construct a new instance without setting its path


FileEntry

public FileEntry(String path)
Construct a new instance with the specified value for its path

Parameters:
path - - the value for path

FileEntry

public FileEntry(String path,
                 String contents)
Construct a new instance with the specified path and file contents

Parameters:
path - - the value for path
contents - - the contents of the file, as a String
Method Detail

isDirectory

public boolean isDirectory()
Return false to indicate that this entry represents a file

Specified by:
isDirectory in interface FileSystemEntry
Specified by:
isDirectory in class AbstractFileSystemEntry
Returns:
false

getSize

public long getSize()
Return the size of this file

Returns:
the file size in bytes

setContents

public void setContents(String contents)
Set the contents of the file represented by this entry

Parameters:
contents - - the String whose bytes are used as the contents

setContents

public void setContents(byte[] contents)
Set the contents of the file represented by this entry

Parameters:
contents - - the byte[] used as the contents

createInputStream

public InputStream createInputStream()
Create and return an InputStream for reading the contents of the file represented by this entry

Returns:
an InputStream

createOutputStream

public OutputStream createOutputStream(boolean append)
Create and return an OutputStream for writing the contents of the file represented by this entry

Parameters:
append - - true if the OutputStream should append to any existing contents false if any existing contents should be overwritten
Returns:
an OutputStream
Throws:
FileSystemException - - if an error occurs creating or initializing the OutputStream

cloneWithNewPath

public FileSystemEntry cloneWithNewPath(String path)
Return a new FileSystemEntry that is a clone of this object, except having the specified path

Parameters:
path - - the new path value for the cloned file system entry
Returns:
a new FileSystemEntry that has all the same values as this object except for its path

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2014. All rights reserved.