Class AbstractTranslator
- java.lang.Object
-
- com.feedzai.commons.sql.abstraction.engine.AbstractTranslator
-
- Direct Known Subclasses:
DB2Translator,H2Translator,MySqlTranslator,OracleTranslator,PostgreSqlTranslator,SqlServerTranslator
public abstract class AbstractTranslator extends Object
Abstract translator to be extended by specific implementations. This class already provides translations that are common to all databases.- Since:
- 2.0.0
- Author:
- Rui Vilao (rui.vilao@feedzai.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.inject.InjectorinjectorThe Guice injector.protected PdbPropertiespropertiesThe properties in place.
-
Constructor Summary
Constructors Constructor Description AbstractTranslator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidinject(Expression... objs)Injects dependencies on the given objects.protected voidinject(Collection<? extends Expression> objs)Injects dependencies on the given objects.protected Stringjoin(Collection<?> list, String delimiter)Joins a collection of objects given the delimiter.protected UnionrowsToUnion(List<Expression> rows)Transform values' rows into a union.abstract Stringtranslate(AlterColumn ac)TranslatesName.abstract Stringtranslate(DbColumn dc)TranslatesDbColumn.abstract Stringtranslate(DropPrimaryKey dpk)TranslatesDropPrimaryKey.abstract Stringtranslate(Rename r)TranslatesRename.Stringtranslate(Between b)TranslatesBetween.Stringtranslate(Case aCase)Translates Case.abstract Stringtranslate(Cast cast)Translates Cast.Stringtranslate(Coalesce c)TranslatesCoalesce.Stringtranslate(Concat concat)Transform the concat keyword.Stringtranslate(Delete d)TranslatesDelete.abstract Stringtranslate(Function f)TranslatesFunction.Stringtranslate(Join j)TranslatesJoin.Stringtranslate(K k)TranslatesK.Stringtranslate(Literal l)TranslatesLiteral.abstract Stringtranslate(Modulo m)TranslatesModulo.Stringtranslate(Name n)TranslatesName.abstract Stringtranslate(Query q)TranslatesQuery.abstract Stringtranslate(RepeatDelimiter rd)TranslatesRepeatDelimiter.abstract Stringtranslate(StringAgg stringAgg)TranslatesStringAgg.Stringtranslate(Truncate t)TranslatesTruncate.Stringtranslate(Union union)TranslatesUnion.Stringtranslate(Update u)TranslatesUpdate.Stringtranslate(Values values)Translates Values.Stringtranslate(Values.Row row)Translates Values.Row.abstract Stringtranslate(View v)TranslatesView.Stringtranslate(When when)Translates When.Stringtranslate(With with)abstract StringtranslateEscape()Translates the escape character.abstract StringtranslateFalse()Translates the boolean false.abstract StringtranslateTrue()Translates the boolean true.protected StringtranslateUpdate(Update update)TranslatesUpdate.protected StringtranslateUpdateFrom(Update update)TranslatesUpdateconsidering the FROM clause.protected StringtranslateUpdateSetClause(Update update)TranslatesUpdateSET clause.
-
-
-
Field Detail
-
properties
@Inject protected PdbProperties properties
The properties in place.
-
injector
@Inject protected com.google.inject.Injector injector
The Guice injector.
-
-
Method Detail
-
inject
protected void inject(Expression... objs)
Injects dependencies on the given objects.- Parameters:
objs- The objects to be injected.
-
inject
protected void inject(Collection<? extends Expression> objs)
Injects dependencies on the given objects.- Parameters:
objs- The objects to be injected.
-
join
protected String join(Collection<?> list, String delimiter)
Joins a collection of objects given the delimiter.- Parameters:
list- The collection of objects to join.delimiter- The delimiter.- Returns:
- A String representing the given objects separated by the delimiter.
-
translate
public String translate(Name n)
TranslatesName.- Parameters:
n- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Between b)
TranslatesBetween.- Parameters:
b- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Coalesce c)
TranslatesCoalesce.- Parameters:
c- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Delete d)
TranslatesDelete.- Parameters:
d- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Join j)
TranslatesJoin.- Parameters:
j- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(K k)
TranslatesK.- Parameters:
k- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Literal l)
TranslatesLiteral.- Parameters:
l- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Truncate t)
TranslatesTruncate.- Parameters:
t- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public String translate(Update u)
TranslatesUpdate.- Parameters:
u- The object to translate.- Returns:
- The string representation of the given object.
-
translateUpdate
protected String translateUpdate(Update update)
TranslatesUpdate.- Parameters:
update- The update to translate.- Returns:
- The string representation of the given object.
-
translateUpdateFrom
protected String translateUpdateFrom(Update update)
TranslatesUpdateconsidering the FROM clause.- Parameters:
update- The update to translate.- Returns:
- The string representation of the given object.
-
translateUpdateSetClause
protected String translateUpdateSetClause(Update update)
TranslatesUpdateSET clause.- Parameters:
update- The update to translate.- Returns:
- The string representation of the SET clause.
-
translate
public String translate(When when)
Translates When.- Parameters:
when- a when.- Returns:
- when translation.
-
translate
public String translate(Case aCase)
Translates Case.- Parameters:
aCase- a case.- Returns:
- case translation.
-
translate
public abstract String translate(Cast cast)
Translates Cast.- Parameters:
cast- a cast expression.- Returns:
- cast translation.
-
translate
public String translate(Union union)
TranslatesUnion.- Parameters:
union- a union.- Returns:
- union translation.
-
translate
public String translate(Values values)
Translates Values.- Parameters:
values- a values.- Returns:
- values translation.
-
translate
public String translate(Values.Row row)
Translates Values.Row.- Parameters:
row- a values.row.- Returns:
- values.row translation.
-
rowsToUnion
protected Union rowsToUnion(List<Expression> rows)
Transform values' rows into a union.- Parameters:
rows- the values' rows- Returns:
- the resulting union
-
translate
public String translate(Concat concat)
Transform the concat keyword.- Parameters:
concat- the concat.- Returns:
- the translated concat.
-
translateEscape
public abstract String translateEscape()
Translates the escape character.- Returns:
- The string representation of the escape character.
-
translateTrue
public abstract String translateTrue()
Translates the boolean true.- Returns:
- The string representation of the true keyword.
-
translateFalse
public abstract String translateFalse()
Translates the boolean false.- Returns:
- The string representation of the false keyword.
-
translate
public abstract String translate(AlterColumn ac)
TranslatesName.- Parameters:
ac- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(DropPrimaryKey dpk)
TranslatesDropPrimaryKey.- Parameters:
dpk- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(Function f)
TranslatesFunction.- Parameters:
f- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(Modulo m)
TranslatesModulo.- Parameters:
m- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(Rename r)
TranslatesRename.- Parameters:
r- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(RepeatDelimiter rd)
TranslatesRepeatDelimiter.- Parameters:
rd- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(Query q)
TranslatesQuery.- Parameters:
q- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(View v)
TranslatesView.- Parameters:
v- The object to translate.- Returns:
- The string representation of the given object.
-
translate
public abstract String translate(DbColumn dc)
TranslatesDbColumn.- Parameters:
dc- The object to translate.- Returns:
- The string representation of the given object.
-
-