com.mucommander.file
Class DummyFile

java.lang.Object
  extended by com.mucommander.file.AbstractFile
      extended by com.mucommander.file.DummyFile
All Implemented Interfaces:
PermissionAccesses, PermissionTypes
Direct Known Subclasses:
SpecialWindowsLocation, TestFile

public class DummyFile
extends AbstractFile

This class is an implementation of AbstractFile which implements all methods as no-op (that do nothing) that return default values. It makes it easy to quickly create a AbstractFile implementation by simply overridding the methods that are needed, for example as an anonymous class inside a method.

This class should NOT be subclassed for proper AbstractFile implementations. It should only be used in certain circumstances that require creating a quick AbstractFile implementation where only a few methods will be used.

Author:
Maxence Bernard

Field Summary
 
Fields inherited from class com.mucommander.file.AbstractFile
DEFAULT_SEPARATOR, fileURL, IO_BUFFER_SIZE, MUST_HINT, MUST_NOT_HINT, SHOULD_HINT, SHOULD_NOT_HINT, windowsDriveRootPattern
 
Fields inherited from interface com.mucommander.file.PermissionTypes
EXECUTE_PERMISSION, READ_PERMISSION, WRITE_PERMISSION
 
Fields inherited from interface com.mucommander.file.PermissionAccesses
GROUP_ACCESS, OTHER_ACCESS, USER_ACCESS
 
Constructor Summary
DummyFile(FileURL url)
           
 
Method Summary
 boolean canChangeDate()
          Implementation notes: always returns false.
 boolean canGetGroup()
          Implementation notes: always returns false.
 boolean canGetOwner()
          Implementation notes: always returns false.
 boolean canRunProcess()
          Implementation notes: always returns false.
 boolean changeDate(long lastModified)
          Implementation notes: always returns false.
 boolean changePermission(int access, int permission, boolean enabled)
          Implementation notes: always returns false.
 void delete()
          Implementation notes: always throws an exception.
 boolean exists()
          Implementation notes: always returns false.
 PermissionBits getChangeablePermissions()
          Implementation notes: returns PermissionBits.EMPTY_PERMISSION_BITS, none of the permission bits can be changed.
 long getDate()
          Implementation notes: always returns 0.
 long getFreeSpace()
          Implementation notes: always returns -1.
 java.lang.String getGroup()
          Implementation notes: always returns null.
 java.io.InputStream getInputStream()
          Implementation notes: always throws an exception.
 java.io.OutputStream getOutputStream(boolean append)
          Implementation notes: always throws an exception.
 java.lang.String getOwner()
          Implementation notes: always returns null.
 AbstractFile getParent()
          Implementation notes: always returns null.
 FilePermissions getPermissions()
          Implementation notes: always returns FilePermissions.EMPTY_FILE_PERMISSIONS.
 RandomAccessInputStream getRandomAccessInputStream()
          Implementation notes: always throws an exception.
 RandomAccessOutputStream getRandomAccessOutputStream()
          Implementation notes: always throws an exception.
 long getSize()
          Implementation notes: always returns -1.
 long getTotalSpace()
          Implementation notes: always returns -1.
 java.lang.Object getUnderlyingFileObject()
          Implementation notes: always returns null.
 boolean hasRandomAccessInputStream()
          Implementation notes: always returns false.
 boolean hasRandomAccessOutputStream()
          Implementation notes: always returns false.
 boolean isDirectory()
          Implementation notes: always returns false.
 boolean isSymlink()
          Implementation notes: always returns false.
 AbstractFile[] ls()
          Implementation notes: always throws an exception.
 void mkdir()
          Implementation notes: always throws an exception.
 AbstractProcess runProcess(java.lang.String[] tokens)
          Implementation notes: always throws an exception.
 void setParent(AbstractFile parent)
          Implementation notes: no-op, does nothing with the specified parent.
 
Methods inherited from class com.mucommander.file.AbstractFile
addTrailingSeparator, calculateChecksum, calculateChecksum, calculateChecksum, changePermissions, changePermissions, checkCopyPrerequisites, copyRecursively, copyStream, copyTo, deleteRecursively, deleteRecursively, equals, getAbsolutePath, getAbsolutePath, getAncestor, getAncestor, getCanonicalFile, getCanonicalPath, getCanonicalPath, getChild, getChildSilently, getCopyToHint, getDirectChild, getExtension, getExtension, getIcon, getIcon, getInputStream, getJavaNetURL, getMoveToHint, getName, getNameWithoutExtension, getParentArchive, getParentSilently, getPermissionsString, getRoot, getSeparator, getTopAncestor, getURL, hasAncestor, hasAncestor, hashCode, importPermissions, importPermissions, isBrowsable, isHidden, isParentOf, isRoot, ls, ls, mkdir, mkdirs, mkfile, mkfile, moveTo, removeTrailingSeparator, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DummyFile

public DummyFile(FileURL url)
Method Detail

getDate

public long getDate()
Implementation notes: always returns 0.

Specified by:
getDate in class AbstractFile
Returns:
this file's last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)

canChangeDate

public boolean canChangeDate()
Implementation notes: always returns false.

Specified by:
canChangeDate in class AbstractFile
Returns:
true if this file's date can be changed using AbstractFile.changeDate(long)

changeDate

public boolean changeDate(long lastModified)
Implementation notes: always returns false.

Specified by:
changeDate in class AbstractFile
Parameters:
lastModified - last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
Returns:
true if date was changed successfully.

getSize

public long getSize()
Implementation notes: always returns -1.

Specified by:
getSize in class AbstractFile
Returns:
this file's size in bytes, 0 if this file doesn't exist, -1 if the size is undetermined

getParent

public AbstractFile getParent()
                       throws java.io.IOException
Implementation notes: always returns null.

Specified by:
getParent in class AbstractFile
Returns:
this file's parent, null if it doesn't have one
Throws:
java.io.IOException - if the parent file could not be instanciated

setParent

public void setParent(AbstractFile parent)
Implementation notes: no-op, does nothing with the specified parent.

Specified by:
setParent in class AbstractFile
Parameters:
parent - the new parent of this file

exists

public boolean exists()
Implementation notes: always returns false.

Specified by:
exists in class AbstractFile
Returns:
true if this file exists

getPermissions

public FilePermissions getPermissions()
Implementation notes: always returns FilePermissions.EMPTY_FILE_PERMISSIONS.

Specified by:
getPermissions in class AbstractFile
Returns:
this file's permissions, as a FilePermissions object

getChangeablePermissions

public PermissionBits getChangeablePermissions()
Implementation notes: returns PermissionBits.EMPTY_PERMISSION_BITS, none of the permission bits can be changed.

Specified by:
getChangeablePermissions in class AbstractFile
Returns:
a bit mask describing the permission bits that can be changed on this file

changePermission

public boolean changePermission(int access,
                                int permission,
                                boolean enabled)
Implementation notes: always returns false.

Specified by:
changePermission in class AbstractFile
Parameters:
access - see PermissionTypes for allowed values
permission - see PermissionAccesses for allowed values
enabled - true to enable the flag, false to disable it
Returns:
true if the permission flag was successfully set for the access type
See Also:
AbstractFile.getChangeablePermissions()

getOwner

public java.lang.String getOwner()
Implementation notes: always returns null.

Specified by:
getOwner in class AbstractFile
Returns:
information about the owner of this file

canGetOwner

public boolean canGetOwner()
Implementation notes: always returns false.

Specified by:
canGetOwner in class AbstractFile
Returns:
true if this file implementation is able to return information about file owners

getGroup

public java.lang.String getGroup()
Implementation notes: always returns null.

Specified by:
getGroup in class AbstractFile
Returns:
information about the owner of this file

canGetGroup

public boolean canGetGroup()
Implementation notes: always returns false.

Specified by:
canGetGroup in class AbstractFile
Returns:
true if this file implementation is able to return information about file groups

isDirectory

public boolean isDirectory()
Implementation notes: always returns false.

Specified by:
isDirectory in class AbstractFile
Returns:
true if this file is a directory, false in any of the cases listed above

isSymlink

public boolean isSymlink()
Implementation notes: always returns false.

Specified by:
isSymlink in class AbstractFile
Returns:
true if this file is a symbolic link

ls

public AbstractFile[] ls()
                  throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
ls in class AbstractFile
Returns:
the children files that this file contains
Throws:
java.io.IOException - if this operation is not possible (file is not browsable) or if an error occurred.

mkdir

public void mkdir()
           throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
mkdir in class AbstractFile
Throws:
java.io.IOException - if the directory could not be created, either because this file already exists or for any other reason.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
getInputStream in class AbstractFile
Returns:
an InputStream to read the contents of this file
Throws:
java.io.IOException - in any of the cases listed above

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
getOutputStream in class AbstractFile
Parameters:
append - if true, data written to the OutputStream will be appended to the end of this file. If false, any existing data this file contains will be discarded and overwritten.
Returns:
an OuputStream to write the contents of this file
Throws:
java.io.IOException - in any of the cases listed above

hasRandomAccessInputStream

public boolean hasRandomAccessInputStream()
Implementation notes: always returns false.

Specified by:
hasRandomAccessInputStream in class AbstractFile
Returns:
true if the underlying filesystem has support for random access input streams

getRandomAccessInputStream

public RandomAccessInputStream getRandomAccessInputStream()
                                                   throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
getRandomAccessInputStream in class AbstractFile
Returns:
a RandomAccessInputStream to read the contents of this file with random access
Throws:
java.io.IOException - in any of the cases listed above

hasRandomAccessOutputStream

public boolean hasRandomAccessOutputStream()
Implementation notes: always returns false.

Specified by:
hasRandomAccessOutputStream in class AbstractFile
Returns:
true if the underlying filesystem has support for random access output streams

getRandomAccessOutputStream

public RandomAccessOutputStream getRandomAccessOutputStream()
                                                     throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
getRandomAccessOutputStream in class AbstractFile
Returns:
a RandomAccessOutputStream to write the contents of this file with random access
Throws:
java.io.IOException - in any of the cases listed above

delete

public void delete()
            throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
delete in class AbstractFile
Throws:
java.io.IOException - if this file does not exist or could not be deleted

getFreeSpace

public long getFreeSpace()
Implementation notes: always returns -1.

Specified by:
getFreeSpace in class AbstractFile
Returns:
the free space (in bytes) on the disk/volume where this file is, -1 if this information is not available.

getTotalSpace

public long getTotalSpace()
Implementation notes: always returns -1.

Specified by:
getTotalSpace in class AbstractFile
Returns:
the total space (in bytes) of the disk/volume where this file is, -1 if this information is not available

getUnderlyingFileObject

public java.lang.Object getUnderlyingFileObject()
Implementation notes: always returns null.

Specified by:
getUnderlyingFileObject in class AbstractFile
Returns:
the file Object of the underlying API providing access to the filesystem, null if there is none

canRunProcess

public boolean canRunProcess()
Implementation notes: always returns false.

Specified by:
canRunProcess in class AbstractFile
Returns:
true if it's possible to run processes on the underlying file system, false otherwise.

runProcess

public AbstractProcess runProcess(java.lang.String[] tokens)
                           throws java.io.IOException
Implementation notes: always throws an exception.

Specified by:
runProcess in class AbstractFile
Parameters:
tokens - command and its arguments for the process to create.
Returns:
a process executing the specified command tokens using this file as a working directory.
Throws:
java.io.IOException - thrown if an error occured while creating the process, if the current file is not a directory or if the operation is not supported.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard