Holger's
Java API

com.antelmann.imagedb
Class SQLImageDB

java.lang.Object
  extended by com.antelmann.imagedb.SQLImageDB
All Implemented Interfaces:
ImageDB, Licensed

public class SQLImageDB
extends Object
implements ImageDB, Licensed

a JDBC implementation of an ImageDB

Author:
Holger Antelmann

Field Summary
protected  String attrImageField
          foreign key field to idField in imageTableName
protected  String attrKeyField
          string field
protected  String attrTableName
          containing image attributes as properties
protected  String attrValueField
          string field
protected  String descriptionField
          longvarchar field
protected  String idField
          number
protected  String imageField
          blob field
protected  String imageTableName
           
protected  String thumbnailField
          blob field
protected  String timeField
          timestamp field
protected  String titleField
          string field
protected  String typeField
          string field
protected  String urlField
          string field
 
Constructor Summary
SQLImageDB(Connection con)
          uses empty properties, which results in the use of defaults
SQLImageDB(Connection con, Properties props)
           
 
Method Summary
 boolean contains(ImageHolder ih)
          determines whether an ImageHolder with the id of the given ImageHolder resides in the database
 boolean delete(ImageHolder ih)
          deletes the given entry from the database completely
protected  int generateNewID()
          takes the maximum existing id and adds one
 Connection getConnection()
           
 Collection<ImageHolder> getImageHolders(Filter<ImageHolder> filter, ImageHolder.Field... fields)
          retrieves a collection of ImageHolder objects; note that the returned ImageHolder objects may not contain more than the ID, initially.
 ImageHolder insert(ImageHolder ih)
          inserts the image holder information to the database.
 int numberOfImageHolders()
          returns the total number of ImageHolder objects in the database
 ImageHolder retrieve(ImageHolder ih, ImageHolder.Field... field)
          loads the specified fields from the database into the given ImageHolder and returns the same.
 void store(ImageHolder ih, ImageHolder.Field... field)
          updates the specified ImageHolder fields in the database based on the given object; the entry must exist before calling this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageTableName

protected String imageTableName

idField

protected String idField
number


timeField

protected String timeField
timestamp field


imageField

protected String imageField
blob field


thumbnailField

protected String thumbnailField
blob field


descriptionField

protected String descriptionField
longvarchar field


urlField

protected String urlField
string field


typeField

protected String typeField
string field


titleField

protected String titleField
string field


attrTableName

protected String attrTableName
containing image attributes as properties


attrImageField

protected String attrImageField
foreign key field to idField in imageTableName


attrKeyField

protected String attrKeyField
string field


attrValueField

protected String attrValueField
string field

Constructor Detail

SQLImageDB

public SQLImageDB(Connection con)
uses empty properties, which results in the use of defaults


SQLImageDB

public SQLImageDB(Connection con,
                  Properties props)
Method Detail

generateNewID

protected int generateNewID()
                     throws SQLException
takes the maximum existing id and adds one

Throws:
SQLException

getConnection

public Connection getConnection()

contains

public boolean contains(ImageHolder ih)
                 throws DatabaseException
Description copied from interface: ImageDB
determines whether an ImageHolder with the id of the given ImageHolder resides in the database

Specified by:
contains in interface ImageDB
Throws:
DatabaseException

insert

public ImageHolder insert(ImageHolder ih)
                   throws DatabaseException
Description copied from interface: ImageDB
inserts the image holder information to the database. The id of the given ImageHolder is completely ignored. The id of the returned ImageHolder may be different and corresponds to the entry actually residing in the database after the call. The returned object may, however, be the same as the one passed in. All fields of the given ImageHolder will be set to be retrieved.

Specified by:
insert in interface ImageDB
Returns:
the object (with its id) as it then resides in the database
Throws:
DatabaseException
See Also:
ImageHolder.isRetrieved(ImageHolder.Field)

store

public void store(ImageHolder ih,
                  ImageHolder.Field... field)
           throws DatabaseException
Description copied from interface: ImageDB
updates the specified ImageHolder fields in the database based on the given object; the entry must exist before calling this method. If no field is specified, all fields will be retrieved. All specified fields will be set to be retrieved, all others will be false (as they may differ hereafter).

Specified by:
store in interface ImageDB
Throws:
DatabaseException
See Also:
ImageHolder.isRetrieved(ImageHolder.Field)

delete

public boolean delete(ImageHolder ih)
               throws DatabaseException
deletes the given entry from the database completely

Specified by:
delete in interface ImageDB
Returns:
true only if the ImageHolder existed before and is now deleted
Throws:
DatabaseException

numberOfImageHolders

public int numberOfImageHolders()
                         throws DatabaseException
Description copied from interface: ImageDB
returns the total number of ImageHolder objects in the database

Specified by:
numberOfImageHolders in interface ImageDB
Throws:
DatabaseException

retrieve

public ImageHolder retrieve(ImageHolder ih,
                            ImageHolder.Field... field)
                     throws DatabaseException
Description copied from interface: ImageDB
loads the specified fields from the database into the given ImageHolder and returns the same. If no field is specified, all fields will be retrieved. All specified fields will be marked as retrieved.

Specified by:
retrieve in interface ImageDB
Throws:
DatabaseException
See Also:
ImageHolder.isRetrieved(ImageHolder.Field)

getImageHolders

public Collection<ImageHolder> getImageHolders(Filter<ImageHolder> filter,
                                               ImageHolder.Field... fields)
                                        throws DatabaseException
Description copied from interface: ImageDB
retrieves a collection of ImageHolder objects; note that the returned ImageHolder objects may not contain more than the ID, initially. To determine, which fields have been retrieved from the database, use isRetrieved(ImageHolder.Field) on the ImageHolder object.

Specified by:
getImageHolders in interface ImageDB
Parameters:
filter - limits the returned collection to those ImageHolders that are accepted by the filter; null is allowed (then, all ImageHolder objects are returned)
fields - defines what fields are pre-initialized, before the filter may see it - other than the id; if no fields are given, no other fields are loaded (this semantic is different from retrieve
Throws:
DatabaseException
See Also:
ImageHolder.isRetrieved(ImageHolder.Field), ImageDB.retrieve(ImageHolder, ImageHolder.Field...)


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