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

Quick Search    Search Deep

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

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

public class Image
extends SimpleContent

The Image class contains a reference to a File, and some metadata (for now a simple caption).

There are now two ways to use Images - the normal way, or with the ImageLibrary. delete and duplicate behave differently in each case.

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

Field Summary
protected  java.lang.String Caption
          The Caption of the image
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
protected  int FileId
          The Image File (a File)
protected  int ImageCatId
          The id of the ImageCategory the image belongs to
protected  int ThumbnailId
          The Image thumbnail (a File)
protected  java.lang.String Title
          The image's title of the image
protected  boolean UseImageLibrary
          Whether we are using the Image Library
 
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
Image()
          Construct a new blank Image, giving it a new unique ID.
Image(int id)
          Get a Image from the database, given an id.
 
Method Summary
 com.RuntimeCollective.webapps.bean.Duplicable customiseDuplicate(com.RuntimeCollective.webapps.bean.Duplicable duplicate)
          The Image version of this method actually duplicates the File composed in the original Image, unless we're using the image library.
 void delete()
          Delete this Image from the database.
 java.lang.String getCaption()
          Get the Caption
 java.lang.String getDescription()
          Get the description Returns the Caption
 File getFile()
          Get the Image File
 com.RuntimeCollective.sitemap.bean.ImageCategory getImageCategory()
          Get the ImageCategory the image belongs to.
 File getThumbnail()
          Get the Image thumbnail.
 java.lang.String getTitle()
          Get the title Returns the title
 java.util.Collection getUsedCSLs()
          Returns a Collection of all ContentSiteLocations that use this image
 boolean getUseImageLibrary()
          Get whether we are using the Image Library
 boolean isValid()
          Returns if the Image has a valid File attached
 void save()
          Save this Image to the database.
 void setCaption(java.lang.String caption)
          Set the Caption
 void setFile(File file)
          Set the Image File.
 void setImageCategory(com.RuntimeCollective.sitemap.bean.ImageCategory imageCategory)
          Set the ImageCategory the image belongs to.
private  void setThumbnail(File file)
          Set the Image thumbnail.
 void setTitle(java.lang.String title)
          Set the title
 void setUseImageLibrary(boolean useLibrary)
          Set whether we are using the Image Library
 void updateThumbnail()
          Update the thumbnail version of this image.
 java.lang.Object viewFormat(java.lang.String format)
          Get the content in a certain format.
 
Methods inherited from class com.RuntimeCollective.content.bean.SimpleContent
getAuthor, getCreationDate, getId, getLastModifiedDate, getLastModifierUser, makeDuplicate, makeDuplicate, setAuthor, setCreationDate, setDescription, setId, setLastModifiedDate, setLastModifierUser
 
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

Title

protected java.lang.String Title
The image's title of the image


FileId

protected int FileId
The Image File (a File)


Caption

protected java.lang.String Caption
The Caption of the image


UseImageLibrary

protected boolean UseImageLibrary
Whether we are using the Image Library


ImageCatId

protected int ImageCatId
The id of the ImageCategory the image belongs to


ThumbnailId

protected int ThumbnailId
The Image thumbnail (a File)

Constructor Detail

Image

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


Image

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

Method Detail

save

public void save()
          throws java.sql.SQLException
Save this Image 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 Image from the database. This will delete the Image's attributes.

If the image uses the image library, then the File associated with the image will also be deleted. Also, all ContentSiteLocations that have the image as subcontent will have it removed.

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

setTitle

public void setTitle(java.lang.String title)
Set the title

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

getTitle

public java.lang.String getTitle()
Get the title Returns the title

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

getDescription

public java.lang.String getDescription()
Get the description Returns the Caption

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

viewFormat

public java.lang.Object viewFormat(java.lang.String format)
Get the content in a certain format. Only "html", "htmlad", and "thumbnail" are supported for now.

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

setFile

public void setFile(File file)
Set the Image File. Also generate a new thumbnail, if param.useThumbnails is set to true


getFile

public File getFile()
Get the Image File


setCaption

public void setCaption(java.lang.String caption)
Set the Caption


getCaption

public java.lang.String getCaption()
Get the Caption


setUseImageLibrary

public void setUseImageLibrary(boolean useLibrary)
Set whether we are using the Image Library


getUseImageLibrary

public boolean getUseImageLibrary()
Get whether we are using the Image Library


setImageCategory

public void setImageCategory(com.RuntimeCollective.sitemap.bean.ImageCategory imageCategory)
Set the ImageCategory the image belongs to. Is called by ImageCategory.addImage(Image i)


getImageCategory

public com.RuntimeCollective.sitemap.bean.ImageCategory getImageCategory()
Get the ImageCategory the image belongs to.


setThumbnail

private void setThumbnail(File file)
Set the Image thumbnail. Is called by updateThumbnail(). if param.useThumbnails is set to true


getThumbnail

public File getThumbnail()
Get the Image thumbnail.


updateThumbnail

public void updateThumbnail()
                     throws java.io.IOException
Update the thumbnail version of this image.

NOTE: This is called by setFile(), but the image can also be changed if someone calls getFile().setContent(...) - hence this method being public. So: if you change this Image's File, you have to manually update the thumbnail yourself, by calling this method.

I suppose I should subclass File, to ThumbnailedImageFile, and use that instead... this would automatically call its parent Image's updateThumbnail method, when setContent is called. Maybe later!


isValid

public boolean isValid()
Returns if the Image has a valid File attached


getUsedCSLs

public java.util.Collection getUsedCSLs()
Returns a Collection of all ContentSiteLocations that use this image


customiseDuplicate

public com.RuntimeCollective.webapps.bean.Duplicable customiseDuplicate(com.RuntimeCollective.webapps.bean.Duplicable duplicate)
The Image version of this method actually duplicates the File composed in the original Image, unless we're using the image library.

If this image uses the image library (getUseImageLibrary() is true), then the image itself is simply returned.

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