org.alltimeflashdreamer.filelister
Class SQLQueryBuilder

java.lang.Object
  extended byorg.alltimeflashdreamer.filelister.SQLQueryBuilder
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MySQLQueryBuilder

public abstract class SQLQueryBuilder
extends Object
implements Serializable

Title: SQLQueryBuilder

Description: This abstract class defines the methods required by FileLister to get the wellformed SQL strings for the various database accesses. Implementing classes must focus on one specific SQL database server.
Important: Implementing classes need an argument-less constructor.

Organization: All Time Flash Dreamer

Version:
0.5.1
Author:
Copyright (c) 2002-2004 by Florian Steinsiepe
See Also:
Serialized Form

Constructor Summary
SQLQueryBuilder()
           
 
Method Summary
abstract  String getChildCountString(String sNodeID)
          Builds and returns the SQL string which is needed to get the count of the child files (no directories!)
abstract  String getCreateTableString(String sTableName)
          Builds and returns the SQL query string used to build an indexing table within the database where the index tables are stored.
abstract  String getDropTableString(String sTableName)
          Builds and returns the SQL query string used to drop the given table.
protected  FileListerConfig getFileListerConfig()
          Extending classes need to have access to the config object, therefore this method is protected.
protected  String getInsertString(String sTableName)
          Returns the insert SQL string for a PreparedStatement class used by FileLister's Dumpers.
abstract  String getLimitationString()
          Builds and returns the (sub)string of the final SQL string that is responsible for result limitation on the database query's amount of results.
abstract  String getListAllTablesString(String sTableName)
          Builds and returns the SQL query string used to list all the tables that are somehow like (or match) the given one in the current database.
protected  int getLowerLimit()
          Returns the lower limit value (which is 0, if not yet set).
abstract  String getRenameTableString(String sOldTableName, String sNewTableName)
          Builds and returns the SQL query string used to rename the given table.
protected  ArrayList getSearchParameters()
          Returns the whole list of SearchParameters instances, each for one (consecutive) search configuration input.
abstract  String getUpdateNodeIDString(String sTableName, String sNodeID, long lUpdateTime)
          Builds and returns the SQL update string which updates the (unique) node with the given id with the given update/reindexing time.
protected  int getUpperLimit()
          Returns the upper limit value (which is 0, if not yet set).
abstract  String getUserSearchString(String sNodeID, boolean bForResultCount)
          Builds and returns the SQL query string used to get the information specified by the user.
protected  boolean hasFileListerConfig()
          Returns whether a FileListerConfig has already been set or not.
 void setFileListerConfig(FileListerConfig config)
          Sets the config object to be used by the implementing class.
protected  void setLowerLimit(int iLowerLimit)
          Sets the internal lower-limit value to iLowerLimit or 0, if lower than 0.
protected  void setUpperLimit(int iUpperLimit)
          Sets the internal upper-limit value to iUpperLimit or 0, if lower than 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLQueryBuilder

public SQLQueryBuilder()
Method Detail

setFileListerConfig

public final void setFileListerConfig(FileListerConfig config)
Sets the config object to be used by the implementing class.

Parameters:
config - the object which knows everything about the user input

hasFileListerConfig

protected final boolean hasFileListerConfig()
Returns whether a FileListerConfig has already been set or not.

Returns:
config already set?

getFileListerConfig

protected final FileListerConfig getFileListerConfig()
Extending classes need to have access to the config object, therefore this method is protected.

Returns:
the config object or null, if not set

getSearchParameters

protected final ArrayList getSearchParameters()
Returns the whole list of SearchParameters instances, each for one (consecutive) search configuration input.

Returns:
the list of SearchParameters instances

getLowerLimit

protected int getLowerLimit()
Returns the lower limit value (which is 0, if not yet set).

Returns:
the result-count-limitating lower boundary

getUpperLimit

protected int getUpperLimit()
Returns the upper limit value (which is 0, if not yet set).

Returns:
the result-count-limitating upper boundary

getUserSearchString

public abstract String getUserSearchString(String sNodeID,
                                           boolean bForResultCount)
Builds and returns the SQL query string used to get the information specified by the user. This query string needs to be as effective as possible to avoid long loading times and memory overhead.
The boolean indicates whether the result count only or the full table data shall be returned using this method's SQL string.
It's up to the implementing class to use the getLimitationString method to limit the result count as configured in the property file.

Parameters:
sNodeID - the id of the directory to be searched
bForResultCount - whether the SQL string leads to the returning of the result count only or to the returning of the full table data
Returns:
the SQL string which reduces the amount of returned entries as much as possible

getCreateTableString

public abstract String getCreateTableString(String sTableName)
Builds and returns the SQL query string used to build an indexing table within the database where the index tables are stored. Because a new table is created for each separate index, the name of the new table is passed as a method attribute.

Parameters:
sTableName - the name of the index table to be created
Returns:
the fully qualified SQL string

getListAllTablesString

public abstract String getListAllTablesString(String sTableName)
Builds and returns the SQL query string used to list all the tables that are somehow like (or match) the given one in the current database. This is often a highly proprietary mechanism!

Parameters:
sTableName - the name of the table to find the similar/equal ones
Returns:
the fully qualified SQL string to get those table names, if any

getDropTableString

public abstract String getDropTableString(String sTableName)
Builds and returns the SQL query string used to drop the given table.

Parameters:
sTableName - the name of the table to be dropped
Returns:
the fully qualified SQL string

getRenameTableString

public abstract String getRenameTableString(String sOldTableName,
                                            String sNewTableName)
Builds and returns the SQL query string used to rename the given table.

Parameters:
sOldTableName - the name of the table to be renamed
sNewTableName - the name of the table after the renaming
Returns:
the fully qualified SQL string

getUpdateNodeIDString

public abstract String getUpdateNodeIDString(String sTableName,
                                             String sNodeID,
                                             long lUpdateTime)
Builds and returns the SQL update string which updates the (unique) node with the given id with the given update/reindexing time. This method is used to update the parent node of a reindexed section which itself is not updated during reindexing time.

Parameters:
sTableName - the name of the table to be dropped
sNodeID - the id of the (unique) node to be updated with the given time
lUpdateTime - the time to set to the "lastindexed" field
Returns:
the fully qualified SQL string

getLimitationString

public abstract String getLimitationString()
Builds and returns the (sub)string of the final SQL string that is responsible for result limitation on the database query's amount of results.

Returns:
the result-count-limitating SQL string (part)

getChildCountString

public abstract String getChildCountString(String sNodeID)
Builds and returns the SQL string which is needed to get the count of the child files (no directories!) of the given node.

Parameters:
sNodeID - the id of the (unique) node to get the children of
Returns:
the SQL string which runs the query that returns a single result column containing the amount of children of the given node

setLowerLimit

protected void setLowerLimit(int iLowerLimit)
Sets the internal lower-limit value to iLowerLimit or 0, if lower than 0. The lower-limit value is used to avoid the loading of too many FileListerEntry instances and must be supported by / implemented in the extending classes.

Parameters:
iLowerLimit - the new lower limit, but at least 0

setUpperLimit

protected void setUpperLimit(int iUpperLimit)
Sets the internal upper-limit value to iUpperLimit or 0, if lower than 0. The upper-limit value is used to avoid the loading of too many FileListerEntry instances and must be supported by / implemented in the extending classes.

Parameters:
iUpperLimit - the new upper limit, but at least 0

getInsertString

protected final String getInsertString(String sTableName)
Returns the insert SQL string for a PreparedStatement class used by FileLister's Dumpers.

Parameters:
sTableName - the name of the table to insert entries into
Returns:
the fully qualified SQL string for a PreparedStatement