class SqlUtils extends java.lang.Object
Convenience class that offers useful utilities for interacting with relational data sources.
Modifiers | Name | Description |
---|---|---|
static java.text.SimpleDateFormat |
DEFAULT_TIMESTAMP_FORMATER |
default simple date format object |
static java.lang.String |
DEFAULT_TIMESTAMP_FORMAT_STRING |
default simple date format string |
Constructor and description |
---|
SqlUtils
() |
Type Params | Return Type | Name and description |
---|---|---|
|
static java.lang.String |
chunkedWhereClause(java.lang.String fieldName, java.util.Collection<java.lang.String> allItems, int maxItemsPerClause) Accept a list of items and produce the where sub-clauses. |
|
static java.lang.String |
chunkedWhereClauseCaseInsensitive(java.lang.String fieldName, java.util.Collection<java.lang.String> allItems, int maxItemsPerClause) Accept a list of items and produce the where sub-clauses. |
|
static java.lang.String |
chunkedWhereClauseInts(java.lang.String fieldName, java.util.Collection<java.lang.Integer> allItems, int maxItemsPerClause) Accept a list of items and produce the where sub-clauses. |
|
static java.util.Collection<java.lang.String> |
chunkedWhereClauses(java.lang.String fieldName, java.util.Collection<java.lang.String> allItems, int maxItemsPerClause) Return a collection of where clauses that use an 'in' construction to include all items in allItems. |
|
static java.util.Collection<java.lang.String> |
chunkedWhereClausesCaseInsensitive(java.lang.String fieldName, java.util.Collection<java.lang.String> allItems, int maxItemsPerClause) Return a collection of where clauses where the comparison is case insensitive. |
|
static java.util.Collection<java.lang.String> |
chunkedWhereClausesInts(java.lang.String fieldName, java.util.Collection<java.lang.Integer> allItems, int maxItemsPerClause) Accept a list of items and produce a list of where sub-clauses. |
|
static java.lang.String |
codeWhereClause(CodeRefGroup crg, java.lang.String fieldName) Produces clauses like: |
|
static java.lang.String |
comparatorRankOrder(java.lang.String field1, java.lang.String field2, SingleValueDateComparator comp) Returns the SQL chunk for a comparator rank order clause given a field name and a FirstOrLastDateComparator comparator. |
|
static java.lang.String |
comparatorRankOrder(java.lang.String field1, FirstOrLastDateComparator comp) Returns the SQL chunk for a comparator rank order clause given a field name and a FirstOrLastDateComparator comparator. |
|
static java.lang.String |
comparatorWhereClause(java.lang.String field1, java.lang.String field2, FirstOrLastDateComparator comp) Returns a SQL comparator clause for given fields and a FirstOrLastDateComparator comparator. |
|
static java.lang.String |
comparatorWhereClause(java.lang.String field1, java.lang.String field2, SummaryDateComparator comp) Returns a SQL comparator clause for given fields and a SummaryDateComparator comparator. |
|
static java.lang.String |
comparatorWhereClause(java.lang.String field1, java.lang.String field2, SingleValueDateComparator comp) Returns a SQL comparator clause for given fields and a SingleValueDateComparator comparator. |
|
static java.lang.String |
inClause(java.util.Collection<java.lang.String> allItems, boolean quoteItems) Generates the parenthesized list that comes after a SQL 'IN' word. |
|
static java.util.Collection<java.lang.String> |
inClauses(java.util.Collection<java.lang.String> allItems, int maxItemsPerClause, boolean quoteItems) Accept a list of items like [1, 2, 3, 4, 5] and produce a collection of in clauses like: ['(1, 2, 3)', '(4,5)'] |
|
static java.lang.Object |
likeWildcardClause(java.util.Collection<java.lang.String> wildcards, java.lang.String fieldName, java.lang.Boolean appendWildcardCharacter) Create a where in clause. |
|
static java.lang.String |
numberAsString(java.lang.Object value) if value can be parsed as a string, return the string value if it is a number otherwise return null |
|
static java.lang.String |
timestampAsString(java.lang.Object timestamp) if timestamp is a java.sql.timestamp object, return the string formatted if timestamp is a String, just return |
|
static java.sql.Date |
valueAsSqlTime(java.lang.Object date, java.lang.String format) if date is a java.util.date object, return the string formatted if date is a String, just return |
|
static java.util.Date |
valueAsTimestamp(java.lang.Object timestamp, java.lang.String format) if timestamp is a java.sql.timestamp object, return the string formatted if timestamp is a String, just return |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
default simple date format object
default simple date format string
Accept a list of items and produce the where sub-clauses. returns something like: (code in ("1", "2", "3%") or code in ("4", "5", "6")) (lab in ("lab1", "lab2", "lab3") or lab in ("labA", "labB", "labC"))
Accept a list of items and produce the where sub-clauses. returns something like: (code in ("1", "2", "3%") or code in ("4", "5", "6")) (lab in ("lab1", "lab2", "lab3") or lab in ("labA", "labB", "labC"))
Accept a list of items and produce the where sub-clauses. returns something like: (code in ("1", "2", "3%") or code in ("4", "5", "6")) (lab in ("lab1", "lab2", "lab3") or lab in ("labA", "labB", "labC"))
Return a collection of where clauses that use an 'in' construction to include all items in allItems.
Return a collection of where clauses where the comparison is case insensitive.
Accept a list of items and produce a list of where sub-clauses. returns something like: [ 'code in ("1", "2", "3%")', 'code in ("4", "5", "6")' ]
Produces clauses like: (testField in ("1.1", "1,2") OR (testField like "411.%") OR (testField like "412.%"))
Returns the SQL chunk for a comparator rank order clause given a field name and a FirstOrLastDateComparator comparator. Returns statements like: ABS(enc_date - recruitment_date) order_date DESC
field1
- - event/order datefield2
- - recruitment dateReturns the SQL chunk for a comparator rank order clause given a field name and a FirstOrLastDateComparator comparator.
Returns a SQL comparator clause for given fields and a FirstOrLastDateComparator comparator.
field1
- - event/order datefield2
- - recruitment dateReturns a SQL comparator clause for given fields and a SummaryDateComparator comparator.
field1
- - event/order datefield2
- - recruitment dateReturns a SQL comparator clause for given fields and a SingleValueDateComparator comparator.
field1
- - event/order datefield2
- - recruitment dateGenerates the parenthesized list that comes after a SQL 'IN' word. Returns strings like: (1, 2, 3) ('a', 'b', 'c')
Accept a list of items like [1, 2, 3, 4, 5] and produce a collection of in clauses like: ['(1, 2, 3)', '(4,5)']
Create a where in clause. Add wildcard character to search strings. For wildcards: ("1", "2", "3") returns something like: (code like "1%" or code like "2%" or code like "3%")
if value can be parsed as a string, return the string value if it is a number otherwise return null
if timestamp is a java.sql.timestamp object, return the string formatted if timestamp is a String, just return
if date is a java.util.date object, return the string formatted if date is a String, just return
if timestamp is a java.sql.timestamp object, return the string formatted if timestamp is a String, just return