org.fopps.model
Class FileAttachment

java.lang.Object
  |
  +--org.fopps.model.AbstractItem
        |
        +--org.fopps.model.Artefact
              |
              +--org.fopps.model.FileAttachment

public class FileAttachment
extends Artefact

Links a feature to a file. The attached file must exists. If the file is removed during program operation, the name is saved and may be restored later.

See Also:
Config

Field Summary
 
Fields inherited from class org.fopps.model.AbstractItem
ADDED_EVENT, CHANGE_EVENT, name, REMOVED_EVENT
 
Constructor Summary
FileAttachment(java.io.File attachedFile)
           
FileAttachment(java.lang.String pName)
          Constructor for FileAttachment.
FileAttachment(java.lang.String pName, java.lang.String pCategory, java.lang.String pFilename)
          Constructor for FileAttachment.
 
Method Summary
protected  void applyFile(java.io.File pFile)
          Stores name and path from a given file object
 void detach()
          Unlink attached file.
 Filesize fileSize()
          Returns the size in a more readable form
protected  void findFile()
          Searches for the file in the search path, if the the last assigned file disappeared.
 java.io.File getAttachedFile()
          Returns the attachedFile.
 java.lang.String getAttachedFilename()
          Returns the name of the attached file
 java.io.File getFile()
          Returns the corresponding file object of the attachment
 java.lang.String getFileName()
          Returns the name of the attached file (without any path information)
 java.lang.String getFilePath()
          Returns the path of the attached file
static java.lang.String getSearchPath()
          Returns the search path.
 boolean isValid()
          Checks, if artefact is still valid.
 void setAttachedFile(java.io.File pAttachedFile)
          Sets the attachedFile.
 void setFilename(java.lang.String pAttachedFilename)
          Sets the attachedFilename.
 long size()
          Returns the size of the attached file.
 java.lang.String toString()
           
protected  void update(java.io.File pNewFile)
          Updates attached file.
 
Methods inherited from class org.fopps.model.Artefact
getCategory, getCategoryName, setCategory
 
Methods inherited from class org.fopps.model.AbstractItem
addIncoming, addListener, addOutgoing, commitGhostRelations, containsType, copyAttributes, delete, filterElements, fireItemAdded, fireItemChanged, fireItemRemoved, getConstraints, getDescription, getIncoming, getIncomingConstraints, getListeners, getName, getOutgoing, getOutgoingConstraints, getRelationTo, hasConstraints, isBlockEvents, isConnectedWith, notifyListeners, removeAllConstraints, removeAllIncoming, removeAllListener, removeAllOutgoing, removeAllRelations, removeGhostRelations, removeIncoming, removeListener, removeOutgoing, removeRelationTo, setBlockEvents, setDescription, setIncoming, setName, setOutgoing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileAttachment

public FileAttachment(java.lang.String pName)
               throws InvalidArtefactException
Constructor for FileAttachment.

Parameters:
pName -

FileAttachment

public FileAttachment(java.io.File attachedFile)
               throws java.io.IOException,
                      InvalidArtefactException

FileAttachment

public FileAttachment(java.lang.String pName,
                      java.lang.String pCategory,
                      java.lang.String pFilename)
               throws InvalidArtefactException
Constructor for FileAttachment.

Parameters:
pName -
pCategory -
pFilename - File to attach
Method Detail

getFile

public java.io.File getFile()
Returns the corresponding file object of the attachment

Returns:
Correspondig file, if exist, otherwise null

update

protected final void update(java.io.File pNewFile)
                     throws InvalidArtefactException
Updates attached file. Searches the file in the search path and updates name and path, if file was found.

Parameters:
pNewFile - New file to attach
Throws:
InvalidArtefactException - if more than one file matches

findFile

protected void findFile()
                 throws InvalidArtefactException
Searches for the file in the search path, if the the last assigned file disappeared. If the file is found in the search path, the path will be updated. If no file was found, the attachment is detached (invalid).

Throws:
InvalidArtefactException - if more than one file matches

applyFile

protected void applyFile(java.io.File pFile)
Stores name and path from a given file object


getAttachedFilename

public java.lang.String getAttachedFilename()
Returns the name of the attached file

Returns:
String

setFilename

public void setFilename(java.lang.String pAttachedFilename)
                 throws InvalidArtefactException
Sets the attachedFilename. If pAttachedFilename is null, the attachment will dropped

InvalidArtefactException

getSearchPath

public static java.lang.String getSearchPath()
Returns the search path. This path is used to find attached files.

See Also:
Config

getAttachedFile

public java.io.File getAttachedFile()
Returns the attachedFile.

Returns:
File

setAttachedFile

public void setAttachedFile(java.io.File pAttachedFile)
                     throws InvalidArtefactException
Sets the attachedFile.

InvalidArtefactException

detach

public void detach()
Unlink attached file. Name and path are set to null


getFileName

public java.lang.String getFileName()
Returns the name of the attached file (without any path information)


getFilePath

public java.lang.String getFilePath()
Returns the path of the attached file


size

public long size()
Returns the size of the attached file. If file does not exis, -1 is returned


fileSize

public Filesize fileSize()
Returns the size in a more readable form


isValid

public boolean isValid()
Checks, if artefact is still valid. If the attach file does not exist (anymore), isValid returns false.

Overrides:
isValid in class Artefact
Returns:
true, if artefact is valid, otherwise false

toString

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


Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.