|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teiid.connector.jdbc.translator.Translator
public class Translator
Base class for creating source SQL queries and retrieving results. Specific databases should override as necessary.
| Nested Class Summary | |
|---|---|
static class |
Translator.NullOrder
|
| Field Summary | |
|---|---|
static java.util.TimeZone |
DEFAULT_TIME_ZONE
|
| Constructor Summary | |
|---|---|
Translator()
|
|
| Method Summary | |
|---|---|
boolean |
addSourceComment()
Returns true to indicate that SQL should include a comment indicating the session and request ids. |
void |
afterConnectionCreation(java.sql.Connection connection)
Provides a hook to call source specific logic when a connection is created. |
protected void |
afterInitialConnectionCreation(java.sql.Connection connection)
Called exactly once for this source. |
void |
bindValue(java.sql.PreparedStatement stmt,
java.lang.Object param,
java.lang.Class<?> paramType,
int i)
Sets prepared statement parameter i with param. |
java.sql.ResultSet |
executeStoredProcedure(java.sql.CallableStatement statement,
TranslatedCommand command)
This is a generic implementation. |
java.lang.String |
formatDateValue(java.util.Date dateObject)
Format the dateObject (of type date, time, or timestamp) into a string using the DatabaseTimeZone format. |
java.lang.String |
getConnectionTestQuery()
|
ConnectorCapabilities |
getConnectorCapabilities()
Get the capabilties for the source. |
java.util.Calendar |
getDatabaseCalendar()
Gets the database calendar. |
java.lang.Class<? extends ConnectorCapabilities> |
getDefaultCapabilities()
Get the default capabilities class. |
java.lang.String |
getDefaultConnectionTestQuery()
|
Translator.NullOrder |
getDefaultNullOrder()
get the default null ordering |
ConnectorEnvironment |
getEnvironment()
Gets the ConnectorEnvironment used to initialize this
Translator |
java.util.Map<java.lang.String,FunctionModifier> |
getFunctionModifiers()
Return a map of function name in lower case to FunctionModifier. |
int |
getIsValidTimeout()
Returns a positive number if query testing should use the JDBC 4.0 isValid check. |
ILanguageFactory |
getLanguageFactory()
Gets the ILanguageFactory |
java.lang.String |
getSetOperationString(ISetQuery.Operation operation)
Returns the name for a given ISetQuery.Operation |
java.lang.String |
getSourceComment(ExecutionContext context,
ICommand command)
Returns the source comment for |
SQLConversionVisitor |
getSQLConversionVisitor()
Create the SQLConversionVisitor that will perform translation. |
int |
getTimestampNanoPrecision()
Return the precision of timestamp literals. |
TypeFacility |
getTypeFacility()
|
boolean |
hasTimeType()
Return false to indicate that time support should be emulated with timestamps. |
void |
initialize(ConnectorEnvironment env)
Initialize the SQLTranslator. |
void |
registerFunctionModifier(java.lang.String name,
FunctionModifier modifier)
Add the FunctionModifier to the set of known modifiers. |
protected void |
registerSpecificTypeOfOutParameter(java.sql.CallableStatement statement,
IParameter param,
int index)
For registering specific output parameter types we need to translate these into the appropriate java.sql.Types output parameters We will need to match these up with the appropriate standard sql types |
java.lang.String |
replaceElementName(java.lang.String group,
java.lang.String element)
Override to return a name other than the default [group.]element |
java.lang.Object |
retrieveValue(java.sql.CallableStatement results,
int parameterIndex,
java.lang.Class expectedType)
Retrieve the value for the given parameter index |
java.lang.Object |
retrieveValue(java.sql.ResultSet results,
int columnIndex,
java.lang.Class<?> expectedType)
Retrieve the value on the current resultset row for the given column index. |
boolean |
supportsExplicitNullOrdering()
|
java.util.List<?> |
translate(ILanguageObject obj,
ExecutionContext context)
Return a List of translated parts ( ILanguageObjects and Objects), or null
if to rely on the default translation. |
java.util.List<?> |
translateCommand(ICommand command,
ExecutionContext context)
Return a List of translated parts ( ILanguageObjects and Objects), or null
if to rely on the default translation. |
java.util.List<?> |
translateLimit(ILimit limit,
ExecutionContext context)
Return a List of translated parts ( ILanguageObjects and Objects), or null
if to rely on the default translation. |
java.lang.String |
translateLiteralBoolean(java.lang.Boolean booleanValue)
Subclasses should override this method to provide a different sql translation of the literal boolean value. |
java.lang.String |
translateLiteralDate(java.sql.Date dateValue)
Subclasses should override this method to provide a different sql translation of the literal date value. |
java.lang.String |
translateLiteralTime(java.sql.Time timeValue)
Subclasses should override this method to provide a different sql translation of the literal time value. |
java.lang.String |
translateLiteralTimestamp(java.sql.Timestamp timestampValue)
Subclasses should override this method to provide a different sql translation of the literal timestamp value. |
boolean |
useAsInGroupAlias()
Indicates whether group alias should be of the form "...FROM groupA AS X" or "...FROM groupA X". |
boolean |
useParensForJoins()
Set to true to indicate that every branch of a join should have parenthesis. |
boolean |
useParensForSetQueries()
Set to true to indicate that every branch of a set query should have parenthesis, i.e. |
boolean |
usePreparedStatements()
Use PreparedStatements (or CallableStatements) as appropriate for all commands. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.util.TimeZone DEFAULT_TIME_ZONE
| Constructor Detail |
|---|
public Translator()
| Method Detail |
|---|
public void initialize(ConnectorEnvironment env)
throws ConnectorException
env - metadata -
ConnectorExceptionpublic java.util.Calendar getDatabaseCalendar()
JDBCPropertyNames.DATABASE_TIME_ZONE, or
the local time zone if none is specified.
public final ConnectorEnvironment getEnvironment()
ConnectorEnvironment used to initialize this
Translator
public final ILanguageFactory getLanguageFactory()
ILanguageFactory
public java.util.List<?> translate(ILanguageObject obj,
ExecutionContext context)
ILanguageObjects and Objects), or null
if to rely on the default translation. Override with care.
command - context -
public java.util.List<?> translateCommand(ICommand command,
ExecutionContext context)
ILanguageObjects and Objects), or null
if to rely on the default translation.
command - context -
public java.util.List<?> translateLimit(ILimit limit,
ExecutionContext context)
ILanguageObjects and Objects), or null
if to rely on the default translation.
limit - context -
public java.util.Map<java.lang.String,FunctionModifier> getFunctionModifiers()
public void registerFunctionModifier(java.lang.String name,
FunctionModifier modifier)
FunctionModifier to the set of known modifiers.
name - modifier - public java.lang.String translateLiteralBoolean(java.lang.Boolean booleanValue)
'0' or '1'.
booleanValue - Boolean value, never null
public java.lang.String translateLiteralDate(java.sql.Date dateValue)
{d'2002-12-31'}
dateValue - Date value, never null
public java.lang.String translateLiteralTime(java.sql.Time timeValue)
{t'23:59:59'}
See hasTimeType() to represent literal times as timestamps.
timeValue - Time value, never null
public java.lang.String translateLiteralTimestamp(java.sql.Timestamp timestampValue)
{ts'2002-12-31 23:59:59'}.
See getTimestampNanoPrecision() to control the literal
precision.
timestampValue - Timestamp value, never null
public java.lang.String formatDateValue(java.util.Date dateObject)
dateObject -
public boolean addSourceComment()
public boolean useAsInGroupAlias()
public boolean usePreparedStatements()
BindValueVisitor. ILiteral.setBindValue(boolean)
can be used to force a literal to be a bind value.
public boolean useParensForSetQueries()
public boolean hasTimeType()
public java.lang.String getSetOperationString(ISetQuery.Operation operation)
ISetQuery.Operation
operation -
public java.lang.String getSourceComment(ExecutionContext context,
ICommand command)
context - command -
public java.lang.String replaceElementName(java.lang.String group,
java.lang.String element)
group - element -
public int getTimestampNanoPrecision()
public java.lang.String getConnectionTestQuery()
public java.lang.String getDefaultConnectionTestQuery()
public TypeFacility getTypeFacility()
public java.sql.ResultSet executeStoredProcedure(java.sql.CallableStatement statement,
TranslatedCommand command)
throws java.sql.SQLException
java.sql.SQLException
protected void registerSpecificTypeOfOutParameter(java.sql.CallableStatement statement,
IParameter param,
int index)
throws java.sql.SQLException
cstmt - parameter -
java.sql.SQLException
public void bindValue(java.sql.PreparedStatement stmt,
java.lang.Object param,
java.lang.Class<?> paramType,
int i)
throws java.sql.SQLException
stmt - param - paramType - i - cal -
java.sql.SQLException
public java.lang.Object retrieveValue(java.sql.ResultSet results,
int columnIndex,
java.lang.Class<?> expectedType)
throws java.sql.SQLException
results - columnIndex - expectedType -
java.sql.SQLException
public java.lang.Object retrieveValue(java.sql.CallableStatement results,
int parameterIndex,
java.lang.Class expectedType)
throws java.sql.SQLException
results - parameterIndex - expectedType -
java.sql.SQLExceptionprotected void afterInitialConnectionCreation(java.sql.Connection connection)
connection - public void afterConnectionCreation(java.sql.Connection connection)
public int getIsValidTimeout()
JDBCPropertyNames.IS_VALID_TIMEOUT property
public SQLConversionVisitor getSQLConversionVisitor()
SQLConversionVisitor that will perform translation. Typical custom
JDBC connectors will not need to create custom conversion visitors, rather implementors
should override existing Translator methods.
public java.lang.Class<? extends ConnectorCapabilities> getDefaultCapabilities()
getConnectorCapabilities() to
return a capabilities instance.
public ConnectorCapabilities getConnectorCapabilities()
throws ConnectorException
ConnectorExceptionpublic boolean useParensForJoins()
public Translator.NullOrder getDefaultNullOrder()
public boolean supportsExplicitNullOrdering()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||