se.entitymanager.logic.file
Class AbstractFile

java.lang.Object
  extended by se.entitymanager.logic.file.AbstractFile
All Implemented Interfaces:
EntityInterface
Direct Known Subclasses:
DirectoryFile, FileSystemsRootFile, RegularFile, ZipFile, ZippedDirectoryFile, ZippedFile

public abstract class AbstractFile
extends java.lang.Object
implements EntityInterface

An entity that represents an file of the file system.


Field Summary
protected  java.lang.String fileContents
          The contents of this file.
protected  java.lang.String lastModified
          The date of last modification of this file.
protected  java.lang.String name
          The name of this file (without path informations).
protected  AbstractFile parent
          Parent file of this entity.
protected  boolean readable
          Indicates if file is readable.
protected  java.lang.String size
          The size of this file.
protected  boolean writeable
          Indicates if file is writable.
 
Constructor Summary
protected AbstractFile(java.lang.String name, AbstractFile parent)
          Constructs a file entity with name and parent.
 
Method Summary
protected abstract  void copy()
          Copy this file.
protected abstract  void delete()
          Deletes this file.
protected abstract  java.util.List getAllChildren()
          Returns all direct child files.
abstract  java.lang.String getFileContents()
          Returns the contents of this file.
 java.lang.String getLastModified()
          Returns date of modification of this file.
 java.lang.String getName()
          Returns the name of this file without path informations.
protected  AbstractFile getParent()
          Returns the parent file.
 java.lang.String getSize()
          Returns the size of this file.
protected abstract  boolean isFolderish()
          Returns whether this file is folderish.
 boolean isReadable()
          Returns if file is readable.
 boolean isWriteable()
          Returns if file is writable.
protected abstract  void paste()
          Paste the file from the clipboard.
protected abstract  void rename(java.lang.String newName)
          Renames this file to newName.
protected  void setName(java.lang.String name)
          Sets the name of this file.
 java.lang.String toString()
          Returns the name of this file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected AbstractFile parent
Parent file of this entity.


name

protected java.lang.String name
The name of this file (without path informations).


size

protected java.lang.String size
The size of this file.


lastModified

protected java.lang.String lastModified
The date of last modification of this file.


fileContents

protected java.lang.String fileContents
The contents of this file.


readable

protected boolean readable
Indicates if file is readable.


writeable

protected boolean writeable
Indicates if file is writable.

Constructor Detail

AbstractFile

protected AbstractFile(java.lang.String name,
                       AbstractFile parent)
Constructs a file entity with name and parent.

Parameters:
name - name of file (without path information)
parent - parent file of this entity
Method Detail

toString

public java.lang.String toString()
Returns the name of this file.

Overrides:
toString in class java.lang.Object
Returns:
the name of this file
See Also:
getName()

isFolderish

protected abstract boolean isFolderish()
Returns whether this file is folderish.

Folderish files like directories or zip files may contain other files.

Returns:
true if this file is folderish, false otherwise

getAllChildren

protected abstract java.util.List getAllChildren()
                                          throws EntityNotFolderishException
Returns all direct child files.

The objects within the list are instances derived from AbstractFile

Returns:
child files
Throws:
EntityNotFolderishException - if this file is not folderish

rename

protected abstract void rename(java.lang.String newName)
                        throws EntityRenameFailedException
Renames this file to newName.

Parameters:
newName - new name of this file.
Throws:
EntityRenameFailedException - if an error occurred

delete

protected abstract void delete()
                        throws EntityDeletionFailedException
Deletes this file.

Throws:
EntityDeletionFailedException - if an error occurred

copy

protected abstract void copy()
                      throws EntityCopyCutFailedException
Copy this file.

Throws:
EntityCopyCutFailedException - if an error occurred

paste

protected abstract void paste()
                       throws EntityPasteFailedException
Paste the file from the clipboard.

Throws:
EntityPasteFailedException - if an error occurred

getFileContents

public abstract java.lang.String getFileContents()
Returns the contents of this file.

Returns:
size of file

getParent

protected AbstractFile getParent()
Returns the parent file.

Returns:
parent file, null if this file is instance of FileSystemsRootFile

getName

public java.lang.String getName()
Returns the name of this file without path informations.

Returns:
name of file

getSize

public java.lang.String getSize()
Returns the size of this file.

Returns:
size of file

getLastModified

public java.lang.String getLastModified()
Returns date of modification of this file.

Returns:
date of modification of file

isReadable

public boolean isReadable()
Returns if file is readable.

Returns:
true if file is readable, otherwise false

isWriteable

public boolean isWriteable()
Returns if file is writable.

Returns:
true if file is writable, otherwise false

setName

protected void setName(java.lang.String name)
Sets the name of this file.

Parameters:
name - name of file.