org.alltimeflashdreamer.filelister
Class MySQLQueryBuilder

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

public class MySQLQueryBuilder
extends SQLQueryBuilder
implements Serializable

Title: MySQLQueryBuilder

Description: Implementation of the SQLQueryBuilder class, using proprietary SQL of the MySQL 3.23 series. For later version, nothing should change, but there's no guarantee at all...

Organization: All Time Flash Dreamer

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

Constructor Summary
MySQLQueryBuilder()
          Empty constructor, as demanded by the superclass specification.
 
Method Summary
 String getChildCountString(String sNodeID)
          Builds and returns the SQL string which is needed to get the count of the child files (no directories!)
 String getCreateTableString(String sTableName)
          Builds and returns the MySQL query string used to build an indexing table within the database where the index tables are stored.
 String getDropTableString(String sTableName)
          Builds and returns the SQL query string used to drop the given table.
 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.
 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.
 String getRenameTableString(String sOldTableName, String sNewTableName)
          Builds and returns the SQL query string used to rename the given table.
 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.
 String getUserSearchString(String sNodeID, boolean bForResultCount)
          Queries the FileListerConfig for the information needed to build a very specific (and therefore Java-unburdening) SQL string.
 
Methods inherited from class org.alltimeflashdreamer.filelister.SQLQueryBuilder
getFileListerConfig, getInsertString, getLowerLimit, getSearchParameters, getUpperLimit, hasFileListerConfig, setFileListerConfig, setLowerLimit, setUpperLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLQueryBuilder

public MySQLQueryBuilder()
Empty constructor, as demanded by the superclass specification.

See Also:
SQLQueryBuilder
Method Detail

getUserSearchString

public String getUserSearchString(String sNodeID,
                                  boolean bForResultCount)
Queries the FileListerConfig for the information needed to build a very specific (and therefore Java-unburdening) SQL string.
An example SQL string would be:
 select * from content
 where node_id like binary '0011%' and name like '%.html'
 order by name asc limit 0, 500

Specified by:
getUserSearchString in class SQLQueryBuilder
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
See Also:
SQLQueryBuilder.getUserSearchString(java.lang.String, boolean)

getCreateTableString

public String getCreateTableString(String sTableName)
Builds and returns the MySQL 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.
Such a table consists of the following columns:

Specified by:
getCreateTableString in class SQLQueryBuilder
Parameters:
sTableName - the name of the index table to be created
Returns:
the fully qualified MySQL string
See Also:
SQLQueryBuilder.getCreateTableString(java.lang.String)

getListAllTablesString

public 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. In MySQL, this is done using "show tables like '<sTableName>'".

Specified by:
getListAllTablesString in class SQLQueryBuilder
Parameters:
sTableName - the name of the table to find the similar/equal ones
Returns:
the fully qualified MySQL string, as described above

getDropTableString

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

Specified by:
getDropTableString in class SQLQueryBuilder
Parameters:
sTableName - the name of the table to be dropped
Returns:
the fully qualified SQL string

getRenameTableString

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

Specified by:
getRenameTableString in class SQLQueryBuilder
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 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.

Specified by:
getUpdateNodeIDString in class SQLQueryBuilder
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 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. For MySQL, this looks like "LIMIT 0, 50", indicating that the results shall be listed from the beginning (0), at most 50 results at a time.

Specified by:
getLimitationString in class SQLQueryBuilder
Returns:
the result-count-limitating SQL string (part), trimmed (without leading or ending spaces)

getChildCountString

public 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.

Specified by:
getChildCountString in class SQLQueryBuilder
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