com.townleyenterprises.persistence
Class SQLFilterAdapter

java.lang.Object
  extended bycom.townleyenterprises.persistence.SQLFilterAdapter

public final class SQLFilterAdapter
extends java.lang.Object

This class is responsible for generating SQL given a filter and optional sort specification.

Version:
$Id: SQLFilterAdapter.java,v 1.4 2004/07/28 10:33:59 atownley Exp $
Author:
Andrew S. Townley

Constructor Summary
SQLFilterAdapter(Filter filter)
          This version of the constructor takes the specified Filter instance and generates the SQL necessary to execute the query.
SQLFilterAdapter(Filter filter, java.util.HashMap tablemap)
          This version of the constructor includes the filter along with a map of the classes to the appropriate table names.
SQLFilterAdapter(Filter filter, java.util.HashMap tablemap, java.util.HashMap colmap)
          This version of the constructor includes the filter and a map of the classes to the appropriate table names, but also includes a property to column name mapping for specific classes.
 
Method Summary
 java.lang.Object[] getQueryParameters()
          This method provides access to the query parameters.
 java.lang.String toSQL(java.lang.Class klass, SortSpecification[] sort)
           
 java.lang.String toSQL(java.util.HashMap sortmap)
           
 java.lang.String toSQL(SortSpecification[] sort)
          This method allows for specifying sort specifications to the generated SQL.
 java.lang.String toSQL(java.lang.String what)
          This method provides access to the SQL for this query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLFilterAdapter

public SQLFilterAdapter(Filter filter)
This version of the constructor takes the specified Filter instance and generates the SQL necessary to execute the query.

Parameters:
filter - the filter to be executed

SQLFilterAdapter

public SQLFilterAdapter(Filter filter,
                        java.util.HashMap tablemap)
This version of the constructor includes the filter along with a map of the classes to the appropriate table names.

Parameters:
filter - the filter to be executed
tablemap - the map of the table names

SQLFilterAdapter

public SQLFilterAdapter(Filter filter,
                        java.util.HashMap tablemap,
                        java.util.HashMap colmap)
This version of the constructor includes the filter and a map of the classes to the appropriate table names, but also includes a property to column name mapping for specific classes. The values for the colmap should be HashMap instances mapping the property names to the columns.

Parameters:
filter - the filter to be executed
tablemap - the map of the table names
colmap - the map of the column names for each class
Method Detail

toSQL

public java.lang.String toSQL(java.lang.String what)
This method provides access to the SQL for this query

Parameters:
what - the values to select
Returns:
the SQL

toSQL

public java.lang.String toSQL(SortSpecification[] sort)
This method allows for specifying sort specifications to the generated SQL. They are not given in the constructor, because the same query may be used over and over with only the order being changed.

Note: using this version assumes that all of the properties in the sort specification are not mapped and that they are unique for all classes in the filter.

Returns:
the SQL

toSQL

public java.lang.String toSQL(java.lang.Class klass,
                              SortSpecification[] sort)

toSQL

public java.lang.String toSQL(java.util.HashMap sortmap)

getQueryParameters

public java.lang.Object[] getQueryParameters()
This method provides access to the query parameters.

Returns:
the query parameters as an array


Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.