FeatureManager
Class FeatureManagerMySQL

java.lang.Object
  extended by FeatureManager.FeatureManager
      extended by FeatureManager.FeatureManagerMySQL
Direct Known Subclasses:
WindsurfFeatureManagerMySQL

public abstract class FeatureManagerMySQL
extends FeatureManager

Implements the MySQL-based Feature Manager.


Field Summary
protected  MySQLConnector conn
          The DB connection
protected  MySQLQuery q
          The last SQL query
protected  java.sql.ResultSet rs
          Result of last SQL query
protected  java.lang.String table
          Name of the features table in the database
 
Fields inherited from class FeatureManager.FeatureManager
time
 
Constructor Summary
FeatureManagerMySQL(java.lang.String host, java.lang.String port, java.lang.String usr, java.lang.String pwd, java.lang.String db, java.lang.String table)
          Basic constructor.
 
Method Summary
 void closeConnection()
          Closes the connection to the features DB.
 void closeScan()
          Closes a sequential scan over image features.
 boolean contains(ImageID id)
          Checks whether an image ID is contained in the database.
 int countDBImages()
          Returns the number of images in the feature DB.
 int countDBRegions()
          Returns the number of regions in the feature DB.
 int countRegions(ImageID id)
          Returns the number of regions of the image with a given ID.
 int countRegions(java.lang.String parameters)
          Returns the total number of regions in the features DB.
 void createConnection()
          Connects to the feature DB.
protected abstract  Image createImage(ImageID id, java.sql.ResultSet rs)
          Creates a new Image given the image ID from the result of a query.
 void createScan()
          Creates a sequential scan over image features.
protected abstract  java.lang.String imageFeatures2String(Image image)
          Generates a string containing the image features.
protected  Image loadFeatures(ImageID id)
          Loads the features of an image from the features DB given the image ID.
 Region loadRegion(ImageID id)
          Loads the features of a region from the features DB given the (global) region ID.
 ImageID nextID()
          Returns an image ID for a new image.
protected  boolean saveFeatures(Image image)
          Saves the features of a given image in the features DB.
 
Methods inherited from class FeatureManager.FeatureManager
getTime, load, loadFeaturesNext, loadNext, resetTime, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected MySQLConnector conn
The DB connection


q

protected MySQLQuery q
The last SQL query


rs

protected java.sql.ResultSet rs
Result of last SQL query


table

protected java.lang.String table
Name of the features table in the database

Constructor Detail

FeatureManagerMySQL

public FeatureManagerMySQL(java.lang.String host,
                           java.lang.String port,
                           java.lang.String usr,
                           java.lang.String pwd,
                           java.lang.String db,
                           java.lang.String table)
Basic constructor.

Parameters:
host - Host name for the DB connection.
port - Port name for the DB connection.
usr - Username for the DB connection.
pwd - Password for the DB connection.
db - Name of the features database.
table - Name of the features table.
Method Detail

createConnection

public void createConnection()
Connects to the feature DB.

Specified by:
createConnection in class FeatureManager

closeConnection

public void closeConnection()
Closes the connection to the features DB.

Specified by:
closeConnection in class FeatureManager

createScan

public void createScan()
Creates a sequential scan over image features.

Specified by:
createScan in class FeatureManager

closeScan

public void closeScan()
Closes a sequential scan over image features.

Specified by:
closeScan in class FeatureManager

countDBImages

public int countDBImages()
Returns the number of images in the feature DB.

Returns:
The number of images in the feature DB, or a negative number if an error occurred.

countDBRegions

public int countDBRegions()
Returns the number of regions in the feature DB.

Returns:
The number of regionsin the feature DB, or a negative number if an error occurred.

nextID

public ImageID nextID()
Returns an image ID for a new image.

Specified by:
nextID in class FeatureManager
Returns:
ImageIDnumerical object not associated to any DB image.

saveFeatures

protected boolean saveFeatures(Image image)
Saves the features of a given image in the features DB.

Specified by:
saveFeatures in class FeatureManager
Parameters:
image - Image whose features are to be saved.
Returns:
true if the features have been successfully saved, false otherwise.

imageFeatures2String

protected abstract java.lang.String imageFeatures2String(Image image)
Generates a string containing the image features.

Parameters:
image - The image whose features are to be saved.
Returns:
A string containing the features of the image.

loadFeatures

protected Image loadFeatures(ImageID id)
Loads the features of an image from the features DB given the image ID.

Specified by:
loadFeatures in class FeatureManager
Parameters:
id - ID of the image to be loaded.
Returns:
Image object containing loaded features (null if no such image exists).

createImage

protected abstract Image createImage(ImageID id,
                                     java.sql.ResultSet rs)
Creates a new Image given the image ID from the result of a query.

Parameters:
id - Image ID.
rs - The result of the issued query.
Returns:
The new Image.

contains

public boolean contains(ImageID id)
Checks whether an image ID is contained in the database.

Overrides:
contains in class FeatureManager
Parameters:
id - Image ID to be searched.
Returns:
true if an image with the given ID exists, false otherwise.

countRegions

public int countRegions(ImageID id)
Returns the number of regions of the image with a given ID.

Parameters:
id - ID of the image to be searched.
Returns:
The number of regions of the requested image.

countRegions

public int countRegions(java.lang.String parameters)
Returns the total number of regions in the features DB.

Parameters:
parameters - Additional "WHERE" clause for the counting query.
Returns:
The total number of regions in the features DB (possibly, only including those satisfying the additional "WHERE" clause).

loadRegion

public Region loadRegion(ImageID id)
Loads the features of a region from the features DB given the (global) region ID.

Parameters:
id - Global ID of the region to be loaded.
Returns:
Region object containing loaded features (null if no such region exist).