Package com.im.commons.db.dml
Class TermEncoder
- java.lang.Object
-
- com.im.commons.db.dml.TermEncoder
-
public final class TermEncoder extends java.lang.Object
Creates SQL fragments for table and column identifiers, value literals and placeholders.
-
-
Constructor Summary
Constructors Constructor Description TermEncoder(DBDatabaseInfo dbInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canEncode(int jdbcType)
Whether it can encode something as String.java.lang.String
encodeColumnRef(java.lang.String columnName)
Encodes reference to a column name.java.lang.String
encodeIdentifier(java.lang.String id)
Encodes an identifier.java.lang.String
encodeLiteral(java.lang.Object value, int jdbcType)
Encodes the literal 'value' in a form suitable for the desired column type (colType).java.lang.String
encodeParamReference(java.lang.String paramName, int jdbcType)
java.lang.String
encodePlaceholder(int jdbcType)
Encodes a placeholder character.java.lang.String
encodeTableColumnRef(SchemaQualifiedName tableName, java.lang.String columnName)
java.lang.String
encodeTableRef(SchemaQualifiedName tableName)
Encodes reference to a table name.DBType
getDBType()
Gets the database type used in thisTermEncoder
.int
getMaxElementsInList()
Gets the maximum number of elements allowed in a SQLIN ()
clause.boolean
isLobPrefetched()
Determines whether a LOB column value is automatically pre-fetched by the database and JDBC.boolean
isOrderByColsMustBeInSelectCols()
Determines whether a column in ORDER BY clause has to be among the SELECT columns.
-
-
-
Constructor Detail
-
TermEncoder
public TermEncoder(DBDatabaseInfo dbInfo)
-
-
Method Detail
-
encodeLiteral
public java.lang.String encodeLiteral(java.lang.Object value, int jdbcType)
Encodes the literal 'value' in a form suitable for the desired column type (colType).- Parameters:
value
- The literal value, possiblynull
jdbcType
- The type of the value.- Returns:
- The 'value' as a SQL literal.
-
encodePlaceholder
public java.lang.String encodePlaceholder(int jdbcType)
Encodes a placeholder character. Typically just a question mark character '?', but can be wrapped in various functions for certainjdbcType
.- Parameters:
jdbcType
- The type of the values that will be set to this placeholder.- Returns:
- The placeholder SQL fragment.
-
encodeIdentifier
public java.lang.String encodeIdentifier(java.lang.String id)
Encodes an identifier.- Parameters:
id
-- Throws:
java.lang.IllegalArgumentException
-
encodeTableRef
public java.lang.String encodeTableRef(SchemaQualifiedName tableName)
Encodes reference to a table name.- Parameters:
tableName
-- Returns:
- The valid identifier (table reference)
-
encodeColumnRef
public java.lang.String encodeColumnRef(java.lang.String columnName)
Encodes reference to a column name.- Parameters:
columnName
-- Returns:
- The valid identifier (column reference)
-
encodeTableColumnRef
public java.lang.String encodeTableColumnRef(SchemaQualifiedName tableName, java.lang.String columnName)
-
encodeParamReference
public java.lang.String encodeParamReference(java.lang.String paramName, int jdbcType)
-
canEncode
public boolean canEncode(int jdbcType)
Whether it can encode something as String.- Parameters:
jdbcType
-
-
getMaxElementsInList
public int getMaxElementsInList()
Gets the maximum number of elements allowed in a SQLIN ()
clause.- Returns:
- The maximum
IN
clause elements. - Since:
- 5.12
-
getDBType
public DBType getDBType()
Gets the database type used in thisTermEncoder
.- Returns:
- The database type.
- Since:
- 5.12
-
isOrderByColsMustBeInSelectCols
public boolean isOrderByColsMustBeInSelectCols()
Determines whether a column in ORDER BY clause has to be among the SELECT columns.- Returns:
true
, ifORDER BY
columns must also be in theSELECT
result.- Since:
- 5.12
-
isLobPrefetched
public boolean isLobPrefetched()
Determines whether a LOB column value is automatically pre-fetched by the database and JDBC.- Returns:
true
, if LOB columns are pre-fetched, otherwisefalse
.- Since:
- 5.12
-
-