|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectSQLSupport
public final class SQLSupport
This class provides support for the SQL query language for a data grid's Sort
and Filter
JavaBeans.
Support is provided here for obtaining a list of supported SQL filter operations. There is also support for
generating two kinds of SQL statements:
Method Summary | |
---|---|
void |
configure(SQLSupportConfig config)
Set the SQLSupportConfig object useed to configure the SQL statements produced by this class. |
String |
createOrderByClause(List sorts)
Create a SQL ORDER BY clause from the list of Sort objects. |
String |
createOrderByFragment(List sorts)
Create a SQL order fragment from the list of Sort objects. |
String |
createWhereClause(List filters)
Create a SQL WHERE clause from the list of Filter objects. |
String |
createWhereFragment(List filters)
Create a SQL WHERE clause from the list of Filter objects. |
static SQLSupport |
getInstance()
Get an instance of this class configured using a default SQLSupportConfig . |
static SQLSupport |
getInstance(DatabaseMetaData databaseMetaData)
Get an instance of this class configured using a SQLSupportConfig that has been configured using
the provided DatabaseMetaData . |
static SQLSupport |
getInstance(SQLSupportConfig config)
Get an instance of this class configured using the provided SQLSupportConfig . |
static String |
lookoupDefaultFilterOperationAbbreviation(String typeHint)
Lookup the default filter operation's abbreviation given a filter type hint abbreviation. |
static Map |
lookupFilterOperationLabels(String typeHint)
Get the readable string labels for a filter operation. |
static FilterOperation |
mapFilterAbbreviationToOperation(String abbrev)
Lookup a filter operation given a filter operation abbreviation. |
static FilterOperation |
mapFilterHintToOperation(FilterOperationHint hint)
Map a FilterOperationHint to a SQL-specific FilterOperation . |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SQLSupport getInstance()
SQLSupportConfig
.
public static SQLSupport getInstance(DatabaseMetaData databaseMetaData) throws SQLException
SQLSupportConfig
that has been configured using
the provided DatabaseMetaData
.
databaseMetaData
- the database metadata used to configure a SQLSupportConfig
object
SQLException
- when an error occurs reading from DatabaseMetaData
public static SQLSupport getInstance(SQLSupportConfig config)
SQLSupportConfig
. The caller
should create and appropriately initialize the config object.
config
- the config object use to configure a SQLSupport instance
public static Map lookupFilterOperationLabels(String typeHint)
Map
contains a set of
filter operation abbreviations mapped to a label for that filter operation. The abbreviations
can be used to lookup the correct filter operation. This method accepts values enumerated
in FilterTypeHint
and available via
FilterTypeHint.getHint()
.
typeHint
- the type hint whose matching operations to lookup
Map
of String abbreviations to readable string names for the operationpublic static String lookoupDefaultFilterOperationAbbreviation(String typeHint)
Lookup the default filter operation's abbreviation given a filter type hint abbreviation. The type hint
should be obtained via FilterTypeHint.getHint()
.
The default filter operations for a given FilterTypeHint string maps to the following FilterOperationHint.
The string returned is the associated FilterOperation's abbreviation
Type Hint | |
FilterTypeHint.DATE | FilterOperationHint.EQUAL |
FilterTypeHint.NUMERIC | FilterOperationHint.EQUAL |
FilterTypeHint.STRING | FilterOperationHint.CONTAINS |
typeHint
- the type hint whose default operation to lookup
public static final FilterOperation mapFilterAbbreviationToOperation(String abbrev)
FilterOperation.getAbbreviation()
.
abbrev
-
public static final FilterOperation mapFilterHintToOperation(FilterOperationHint hint)
FilterOperationHint
to a SQL-specific FilterOperation
. When using SQL as a query
language, all of the operations defined in FilterOperationHint
should be supported.
hint
- the hint
FilterOperation
matching the given hint.public void configure(SQLSupportConfig config)
SQLSupportConfig
object useed to configure the SQL statements produced by this class.
config
- the config objectpublic final String createOrderByFragment(List sorts)
Create a SQL order fragment from the list of Sort
objects. This fragment does not begin with
ORDER BY and is just the fragment for such a clause. If the given list of
sorts contains a sort with sort expression "foo" and sort direction SortDirection.DESCENDING
,
the generated SQL statement will appear as:
foo DESC
sorts
- the list of Sort
objects
public final String createOrderByClause(List sorts)
Create a SQL ORDER BY clause from the list of Sort
objects. This fragment begins with
ORDER BY. If the given list of sorts contains a sort with sort expression "foo" and sort direction
SortDirection.DESCENDING
, the generated SQL statement will appear as:
ORDER BY foo DESC
sorts
- the list of Sort
objects
public String createWhereFragment(List filters)
Create a SQL WHERE clause from the list of Filter
objects. This fragment does not begin with
WHERE. If the given list of sorts contains a Filter with filter expression "foo", operation equals,
and value '42', the generated SQL statement will appear as:
foo = 42When multiple Filters in the list, the filters will be AND'ed together in the generated SQL statement.
filters
- the list of Filter
objects
public String createWhereClause(List filters)
Create a SQL WHERE clause from the list of Filter
objects. This fragment begins with
WHERE. If the given list of sorts contains a Filter with filter expression "foo", operation equals,
and value '42', the generated SQL statement will appear as:
WHERE foo = 42When multiple Filters in the list, the filters will be AND'ed together in the generated SQL statement.
filters
- the list of Filter
objects
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |