Holger's
Java API

com.antelmann.image
Class ImageURLEntry

java.lang.Object
  extended by com.antelmann.db.AbstractDBEntry
      extended by com.antelmann.db.PropertyEntryImpl
          extended by com.antelmann.image.ImageURLEntry
All Implemented Interfaces:
DBEntry, DocumentEntry, PropertyEntry, Taggable<Keyword>, Imageable, GeoEncoded, DetailedString, LifeCycleObject, Localizable, Serializable

public class ImageURLEntry
extends PropertyEntryImpl
implements DocumentEntry, GeoEncoded

ImageEntry serves as a basic wrapper for image information stored in a database. This implementation relies on a weak reference to access the actual image data, which e.g. may be read from a file when calling getImage() which would trigger the method retrieveImage() to retrieve the image.

Author:
Holger Antelmann
See Also:
ImageURLEntrySQLStore, Serialized Form

Nested Class Summary
static class ImageURLEntry.Thumbnail<T extends ImageURLEntry>
           
 
Nested classes/interfaces inherited from interface com.antelmann.db.Taggable
Taggable.Adapter<T extends Tag>
 
Nested classes/interfaces inherited from interface com.antelmann.util.Localizable
Localizable.Adapter
 
Field Summary
 
Fields inherited from class com.antelmann.db.PropertyEntryImpl
propertyChangeSupport, props, um, vcs
 
Fields inherited from interface com.antelmann.db.DBEntry
ENTRY_FLAVOR, ENTRY_LIST_FLAVOR
 
Constructor Summary
ImageURLEntry()
          uses a random id
ImageURLEntry(Object id)
          time is automatically set to current system time
ImageURLEntry(Object id, ImageURLEntry ie)
          creates a new ImageHolder based on the given one - with a different ID
 
Method Summary
 boolean add(Keyword word)
          makes this instance member of the given group
 boolean addKeyword(String keyword)
           
 boolean addRegionTag(SimpleRegionTag tag)
           
 void clear()
          resets all fields
 Date getBeginTime()
          returns getDate()
 InputStream getContent()
          accesses the raw content of this document
 Date getDate()
          simply returns the embedded time as a new Date instance
 String getDescription()
          provides a detailed description of this document
 Image getDisplayIcon()
          returns an image that is suitable for use as an icon for this instance.
 Image getDisplayImage()
          returns an image that represents a visual representation of this instance.
 Date getEndTime()
          always returns null
 GeoPoint getGeoPoint()
           
 Image getImage()
           
 Locale getLocale()
          allows access to the Locale that this instance currently uses to localize its messages,
 String getNotes()
          always returns null
 URL getOriginalLocation()
          returns getURL()
 SimpleRegionTag[] getRegionTags()
           
 Collection<Keyword> getTags()
          lists all groups that this instance is currently a member of (the data is essentially derived from a set)
 Image getThumbnail()
           
 long getTime()
           
 String getTitle()
          returns the title of this document
 URL getURL()
           
 boolean hasKeyword(String keyword)
           
 boolean isTagged(Keyword word)
          allows to determine the membership of the given tag or group
 boolean remove(Keyword word)
          terminates the membership of this instance to the given group
 boolean removeKeyword(String keyword)
           
 boolean removeRegionTag(SimpleRegionTag tag)
           
protected  Image retrieveImage()
          this method is responsible for loading the original image from its original location; this method is called by getImage() if the image is not cached anymore by the weak reference holding the data.
 void setDescription(String description)
           
 void setGeoPoint(GeoPoint gp)
           
protected  void setImageReference(Image image)
          this method merely sets the soft reference to the given image.
 void setLocale(Locale locale, Object context)
          sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.
 void setThumbnail(Image image)
           
 void setTime(Date date)
           
 void setTime(long timeInMillis)
           
 void setTitle(String title)
           
 void setURL(URL url)
           
 String toDetailedString()
          provides full details of this instance in a String.
 String toString()
           
 void updateThumbnail(int maxWidthHeight)
          updates the thumbnail based on the return value of getImage().
 
Methods inherited from class com.antelmann.db.PropertyEntryImpl
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, asProperties, canRedo, canUndo, checkPropertyChange, clearProperties, containsPropertyText, containsValuePattern, equalWithProperties, equalWithProperties, getBoolean, getNumber, getProperties, getProperty, getProperty, getPropertyChangeListeners, getPropertyComparator, getPropertyExtractor, getPropertyExtractor, getPropertyKeys, getStringExtractor, getVetoableChangeListeners, isCaseInsensitive, isChangeListenerSupportEnabled, isKeyIn, isUndoSupport, isVetoableChangeSupportEnabled, putAll, redo, removeProperty, removePropertyChangeListener, removeVetoableChangeListener, setAllFrom, setCaseInsensitive, setChangeListenerSupport, setProperty, setUndoSupported, setVetoableChangeSupport, undo, verifyProperties
 
Methods inherited from class com.antelmann.db.AbstractDBEntry
equals, getID, hashCode, hashEntry, sameEntry
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.antelmann.db.PropertyEntry
getProperties, getProperty, removeProperty, setProperty
 
Methods inherited from interface com.antelmann.db.DBEntry
getID
 

Constructor Detail

ImageURLEntry

public ImageURLEntry()
uses a random id


ImageURLEntry

public ImageURLEntry(Object id)
time is automatically set to current system time


ImageURLEntry

public ImageURLEntry(Object id,
                     ImageURLEntry ie)
              throws IOException
creates a new ImageHolder based on the given one - with a different ID

Throws:
IOException
Method Detail

getLocale

public Locale getLocale()
Description copied from interface: Localizable
allows access to the Locale that this instance currently uses to localize its messages,

Specified by:
getLocale in interface Localizable
Returns:
the current Locale that this instance uses to determine return values for its methods; if null is returned, this instance is expected to use the default Locale of the system.
See Also:
Localizable.setLocale(Locale, Object)

setLocale

public void setLocale(Locale locale,
                      Object context)
Description copied from interface: Localizable
sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.

Specified by:
setLocale in interface Localizable
Parameters:
locale - the Locale that is to be used to determine return values for all methods of this instance; if set to null, the default locale is to be used.
context - a context that may be required for this instance to load the resources for the given locale; this context may be null for objects that do not require an external context. Examples of a context may be a database, a resource file, some map or no context at all.
See Also:
Localizable.getLocale()

retrieveImage

protected Image retrieveImage()
                       throws IOException
this method is responsible for loading the original image from its original location; this method is called by getImage() if the image is not cached anymore by the weak reference holding the data. This implementation retrieves the image from the URL.

Throws:
IOException
See Also:
getURL()

getImage

public Image getImage()
               throws IOException
Throws:
IOException

setImageReference

protected void setImageReference(Image image)
                          throws IOException
this method merely sets the soft reference to the given image. In order to have the given image returned by getImage(), a subclass must provide a method to also ensure that retrieveImage() returns this image (while that method should also call this method!).

Throws:
IOException

clear

public void clear()
resets all fields


toString

public String toString()
Overrides:
toString in class AbstractDBEntry

toDetailedString

public String toDetailedString()
Description copied from interface: DetailedString
provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

Specified by:
toDetailedString in interface DetailedString
Overrides:
toDetailedString in class PropertyEntryImpl
Returns:
a (potentially multi-line) String providing full details on this object instance

getDisplayImage

public Image getDisplayImage()
                      throws IOException
Description copied from interface: Imageable
returns an image that represents a visual representation of this instance. The method may return null;

Specified by:
getDisplayImage in interface Imageable
Throws:
IOException

getDisplayIcon

public Image getDisplayIcon()
                     throws IOException
Description copied from interface: Imageable
returns an image that is suitable for use as an icon for this instance. The method may return null;

Specified by:
getDisplayIcon in interface Imageable
Throws:
IOException

getTitle

public String getTitle()
Description copied from interface: DocumentEntry
returns the title of this document

Specified by:
getTitle in interface DocumentEntry

setTitle

public void setTitle(String title)

getURL

public URL getURL()

setURL

public void setURL(URL url)

getDate

public Date getDate()
simply returns the embedded time as a new Date instance


getTime

public long getTime()

setTime

public void setTime(long timeInMillis)

setTime

public void setTime(Date date)

getDescription

public String getDescription()
Description copied from interface: DocumentEntry
provides a detailed description of this document

Specified by:
getDescription in interface DocumentEntry

setDescription

public void setDescription(String description)

getGeoPoint

public GeoPoint getGeoPoint()
Specified by:
getGeoPoint in interface GeoEncoded

setGeoPoint

public void setGeoPoint(GeoPoint gp)

updateThumbnail

public void updateThumbnail(int maxWidthHeight)
                     throws IOException
updates the thumbnail based on the return value of getImage(). The image is scaled so that it will fit into a square with the given boundary; the thumbnail maintains the original ratio.

Throws:
IOException

setThumbnail

public void setThumbnail(Image image)
                  throws IOException
Throws:
IOException

getThumbnail

public Image getThumbnail()
                   throws IOException
Throws:
IOException

addKeyword

public boolean addKeyword(String keyword)

add

public boolean add(Keyword word)
Description copied from interface: Taggable
makes this instance member of the given group

Specified by:
add in interface Taggable<Keyword>
Parameters:
word - the Group object that this instance is to become a member of
Returns:
true only if the group was actually added to this instance or false if it already was a member of that group

getTags

public Collection<Keyword> getTags()
Description copied from interface: Taggable
lists all groups that this instance is currently a member of (the data is essentially derived from a set)

Specified by:
getTags in interface Taggable<Keyword>

hasKeyword

public boolean hasKeyword(String keyword)

isTagged

public boolean isTagged(Keyword word)
Description copied from interface: Taggable
allows to determine the membership of the given tag or group

Specified by:
isTagged in interface Taggable<Keyword>

removeKeyword

public boolean removeKeyword(String keyword)

remove

public boolean remove(Keyword word)
Description copied from interface: Taggable
terminates the membership of this instance to the given group

Specified by:
remove in interface Taggable<Keyword>
Parameters:
word - the Group that this instance is to be removed from as a member
Returns:
true only if this instance was previously a member of the given group.

getRegionTags

public SimpleRegionTag[] getRegionTags()

removeRegionTag

public boolean removeRegionTag(SimpleRegionTag tag)

addRegionTag

public boolean addRegionTag(SimpleRegionTag tag)

getBeginTime

public Date getBeginTime()
returns getDate()

Specified by:
getBeginTime in interface LifeCycleObject

getEndTime

public Date getEndTime()
always returns null

Specified by:
getEndTime in interface LifeCycleObject

getContent

public InputStream getContent()
                       throws IOException
Description copied from interface: DocumentEntry
accesses the raw content of this document

Specified by:
getContent in interface DocumentEntry
Throws:
IOException

getNotes

public String getNotes()
always returns null

Specified by:
getNotes in interface DocumentEntry

getOriginalLocation

public URL getOriginalLocation()
returns getURL()

Specified by:
getOriginalLocation in interface DocumentEntry


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads