Package org.apache.empire.commons
Class SqlFormat
java.lang.Object
org.apache.empire.commons.SqlFormat
SqlFormat
This class pretty-formats an SQL command.
It may be either overwritten or replaced by a custom implementation
by setting a formatter that implements the SqlFormatter interface
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDefaultSqlFormatter Uses the default implementation to format SQLstatic enumSQL KeyWordstatic interfaceSqlFormatter interface for customization -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected intappend(int beg, int end, boolean indent, boolean newLineAfter, int lev) build()Builds the formatted SQLprotected final Stringprotected SqlFormat.KeyWordfindKeyWord(int pos) protected final intfindNext(char find, int from) protected final intstatic StringFormats an sqlCmd using the current SQL formatterstatic StringFormats an sqlCmd using the current SQL formatterstatic StringFormats an sqlCmd using the current SQL formatterstatic SqlFormat.SqlFormatterReturns the current SLQ Formatterprotected Stringprotected char[]prepareCmd(String sqlCmd) static voidsetFormatter(SqlFormat.SqlFormatter formatter) Replace the current SqlFormatterprotected voidprotected void
-
Field Details
-
log
protected static final org.slf4j.Logger log
-
-
Constructor Details
-
SqlFormat
SqlFormat Constructor- Parameters:
sqlCmd- the SQL command stringparamValues- the parameter valuesparamTypes- the parameter types
-
-
Method Details
-
getFormatter
Returns the current SLQ Formatter- Returns:
- the current SLQ Formatter
-
setFormatter
Replace the current SqlFormatter- Parameters:
formatter- the SQL formatter
-
format
Formats an sqlCmd using the current SQL formatter- Parameters:
sqlCmd- the SQL commandparamValues- the param values to replace query params '?' (optional)paramTypes- the param types for the given param values (optional)- Returns:
- the formatted SQL
-
format
Formats an sqlCmd using the current SQL formatter- Parameters:
sqlCmd- the SQL commandparamValues- the param values to replace query params '?' (optional)- Returns:
- the formatted SQL
-
format
Formats an sqlCmd using the current SQL formatter- Parameters:
sqlCmd- the SQL command- Returns:
- the formatted SQL
-
build
Builds the formatted SQL- Returns:
- the formatted SQL
-
prepareCmd
-
allowBlock
-
append
protected int append(int beg, int end, boolean indent, boolean newLineAfter, int lev) -
nextParamValue
-
findKeyWord
-
skipLiteral
protected void skipLiteral() -
skipParenthesis
protected void skipParenthesis() -
findNext
protected final int findNext(char find, int from) -
findNext
-
combineBlanks
-