Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.content.bean
Class File  view File download File.java

java.lang.Object
  extended bycom.RuntimeCollective.content.bean.SimpleContent
      extended bycom.RuntimeCollective.content.bean.File
All Implemented Interfaces:
Content, com.RuntimeCollective.webapps.bean.Duplicable, com.RuntimeCollective.webapps.bean.EntityBean, java.io.Serializable

public class File
extends SimpleContent

The File class will hold the content of a file, either directly, or via a filename reference. In the first case, the content will be saved in the permanence layer (e.g. database), in the other, only the reference to the file will be kept.

If the latter, then the following runtime parameters must be set:

Version:
$Id: File.java,v 1.27 2003/09/30 15:12:46 joe Exp $

Field Summary
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
protected  java.lang.String FileEnding
          The FileEnding
protected  java.lang.String MimeType
          The MimeType
protected  java.lang.String OriginalFilename
          The OriginalFilename
 
Fields inherited from class com.RuntimeCollective.content.bean.SimpleContent
Author_id, CreationDate, id, LastModifiedDate, LastModifierUser_id
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
File()
          Construct a new blank File, giving it a new unique ID.
File(int id)
          Get a File from the RuntimeDataSource, given an id.
 
Method Summary
 com.RuntimeCollective.webapps.bean.Duplicable customiseDuplicate(com.RuntimeCollective.webapps.bean.Duplicable duplicate)
          The File version of this method actually copies the file on the FileSystem.
 void delete()
          Delete this File from the database.
protected  void deleteExistingFiles()
          Delete the files saved in the filesystem
 void emptyContent()
          A method to empty the content of this file.
 java.lang.String getDescription()
          Get the description Return the original filename and mimetype.
 java.io.File getFile()
          Sometimes, it's just useful to get the raw File itself.
 java.lang.String getFileEnding()
          Get the FileEnding
 java.lang.String getMimeType()
          Get the MimeType
 java.lang.String getOriginalFilename()
          Get the OriginalFilename
 java.lang.String getTitle()
          Get the title Return the filename and mimetype.
 boolean isValid()
          Returns whether this file is valid or not, that is, whether it has valid content set.
 void save()
          Save this File to the database.
 void setContent(java.io.File file)
          Change the content of the File, from a java.io.File
 void setContent(org.apache.struts.upload.FormFile formFile)
          Change the content of the File, from a FormFile
 void setContent(java.io.InputStream inputStream, int length)
          Change the content of the File, from an InputSteam and its size
 void setContent(java.lang.String string)
          Change the content of the File, from a String Be careful: Strings are 8-bit (no strange characters)
 void setFileEnding(java.lang.String fileEnding)
          Set the FileEnding This will delete old files - if the former FileEnding is not null (ie if we are not initialising this bean)
 void setId(int id)
          Set the unique id of this File.
 void setMimeType(java.lang.String mimeType)
          Set the MimeType
 void setOriginalFilename(java.lang.String originalFilename)
          Set the OriginalFilename
 java.lang.Object viewFormat(java.lang.String format)
          Get the File in a certain format.
 
Methods inherited from class com.RuntimeCollective.content.bean.SimpleContent
getAuthor, getCreationDate, getId, getLastModifiedDate, getLastModifierUser, makeDuplicate, makeDuplicate, setAuthor, setCreationDate, setDescription, setLastModifiedDate, setLastModifierUser, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of the database table for this bean type.

See Also:
Constant Field Values

MimeType

protected java.lang.String MimeType
The MimeType


OriginalFilename

protected java.lang.String OriginalFilename
The OriginalFilename


FileEnding

protected java.lang.String FileEnding
The FileEnding

Constructor Detail

File

public File()
     throws java.sql.SQLException
Construct a new blank File, giving it a new unique ID.


File

public File(int id)
     throws java.sql.SQLException
Get a File from the RuntimeDataSource, given an id.

Method Detail

setId

public void setId(int id)
Set the unique id of this File.

Specified by:
setId in interface com.RuntimeCollective.webapps.bean.EntityBean
Overrides:
setId in class SimpleContent

deleteExistingFiles

protected void deleteExistingFiles()
Delete the files saved in the filesystem


save

public void save()
          throws java.sql.SQLException
Save this File to the database.

Specified by:
save in interface com.RuntimeCollective.webapps.bean.EntityBean
Overrides:
save in class SimpleContent

delete

public void delete()
            throws java.sql.SQLException
Delete this File from the database. This also deletes the suitable file(s) from the contentFilesDataDir directory. There may be more than one file to delete if we changed the FileEnding.

Specified by:
delete in interface com.RuntimeCollective.webapps.bean.EntityBean
Overrides:
delete in class SimpleContent

getTitle

public java.lang.String getTitle()
Get the title Return the filename and mimetype.

Specified by:
getTitle in interface Content
Overrides:
getTitle in class SimpleContent

getDescription

public java.lang.String getDescription()
Get the description Return the original filename and mimetype.

Specified by:
getDescription in interface Content
Overrides:
getDescription in class SimpleContent

viewFormat

public java.lang.Object viewFormat(java.lang.String format)
Get the File in a certain format. For now, only "html" is supported, and it gives the URL of where to find the local file.

Specified by:
viewFormat in interface Content
Overrides:
viewFormat in class SimpleContent

setMimeType

public void setMimeType(java.lang.String mimeType)
Set the MimeType


getMimeType

public java.lang.String getMimeType()
Get the MimeType


setOriginalFilename

public void setOriginalFilename(java.lang.String originalFilename)
Set the OriginalFilename


getOriginalFilename

public java.lang.String getOriginalFilename()
Get the OriginalFilename


setFileEnding

public void setFileEnding(java.lang.String fileEnding)
Set the FileEnding This will delete old files - if the former FileEnding is not null (ie if we are not initialising this bean)


getFileEnding

public java.lang.String getFileEnding()
Get the FileEnding


setContent

public void setContent(org.apache.struts.upload.FormFile formFile)
                throws java.lang.RuntimeException
Change the content of the File, from a FormFile


setContent

public void setContent(java.io.File file)
                throws java.lang.RuntimeException
Change the content of the File, from a java.io.File


setContent

public void setContent(java.lang.String string)
                throws java.lang.RuntimeException
Change the content of the File, from a String Be careful: Strings are 8-bit (no strange characters)


emptyContent

public void emptyContent()
                  throws java.lang.RuntimeException
A method to empty the content of this file.


isValid

public boolean isValid()
Returns whether this file is valid or not, that is, whether it has valid content set.


getFile

public java.io.File getFile()
Sometimes, it's just useful to get the raw File itself. I'm sorry, but it is.

If there's more than one, just return the first one found. (There shouldn't be.)


setContent

public void setContent(java.io.InputStream inputStream,
                       int length)
                throws java.lang.RuntimeException
Change the content of the File, from an InputSteam and its size


customiseDuplicate

public com.RuntimeCollective.webapps.bean.Duplicable customiseDuplicate(com.RuntimeCollective.webapps.bean.Duplicable duplicate)
The File version of this method actually copies the file on the FileSystem.

Specified by:
customiseDuplicate in interface com.RuntimeCollective.webapps.bean.Duplicable
Overrides:
customiseDuplicate in class SimpleContent