se.entitymanager.logic.file
Class FileLogic

java.lang.Object
  extended by se.entitymanager.logic.file.FileLogic

public class FileLogic
extends java.lang.Object

A class to provide basic file functionalities.


Nested Class Summary
(package private)  class FileLogic.CopyDirVisitor
          Inner Class used to copy whole directories.
(package private)  class FileLogic.FileTreeWalker
          Inner Class used to pass recursively through the file lists.
 
Field Summary
private  java.io.File clipboardFile
          The file that represents the clipboard.
private static FileLogic fileLogic
          Static instance.
private  FileSystemsRootFile rootObject
          Root of file systems.
 
Constructor Summary
private FileLogic()
          Constructs the class to provide file functionalities.
 
Method Summary
protected  void copy(java.io.File file)
          Copies a file to the clipboard.
protected  java.lang.String createTruncatedZipEntryName(java.util.zip.ZipEntry zipEntry)
          Returns the name of a file within a zip file.
protected  void delete(java.io.File file)
          Deletes a file.
 java.io.File getClipboardFile()
          Returns the file in the clipboard.
 FileSystemsRootFile getFileSystemsRoot()
          Returns the root of file systems.
static FileLogic getInstance()
          Returns the instance of file logic.
protected  void paste(java.io.File destiny)
          Pastes a file from the clipboard clipboardFile to the destination
protected  java.io.File rename(java.io.File file, java.lang.String newName)
          Renames a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileLogic

private static FileLogic fileLogic
Static instance.

See Also:
getInstance()

rootObject

private FileSystemsRootFile rootObject
Root of file systems.


clipboardFile

private java.io.File clipboardFile
The file that represents the clipboard.

Constructor Detail

FileLogic

private FileLogic()
Constructs the class to provide file functionalities.

Method Detail

getInstance

public static FileLogic getInstance()
Returns the instance of file logic.

Returns:
instance of file logic.

getFileSystemsRoot

public FileSystemsRootFile getFileSystemsRoot()
Returns the root of file systems.

Returns:
root of file systems.

getClipboardFile

public java.io.File getClipboardFile()
Returns the file in the clipboard.

Returns:
clipboardFile.

createTruncatedZipEntryName

protected java.lang.String createTruncatedZipEntryName(java.util.zip.ZipEntry zipEntry)
Returns the name of a file within a zip file.

File names are stored with full path information in zip files.

Parameters:
zipEntry - the zip entry of the file
Returns:
name of zipped file (without path information)

rename

protected java.io.File rename(java.io.File file,
                              java.lang.String newName)
                       throws FileRenameFailedException
Renames a file.

Parameters:
file - the file to rename.
newName - the new name
Returns:
a new file object of the new file.
Throws:
FileRenameFailedException - if an error occurred

copy

protected void copy(java.io.File file)
             throws FileCopyCutFailedException
Copies a file to the clipboard.

Parameters:
file - the file to be copied.
Throws:
FileCopyCutFailedException - if an error occurred

paste

protected void paste(java.io.File destiny)
              throws FilePasteFailedException
Pastes a file from the clipboard clipboardFile to the destination

Throws:
FilePasteFailedException - if an error occurred

delete

protected void delete(java.io.File file)
               throws FileDeletionFailedException
Deletes a file. If File is directory, also delete its content.

Parameters:
file - the file to delete.
Throws:
FileRenameFailedException - if an error occurred
FileDeletionFailedException