public abstract class DBSQLBuilder extends Object implements Appendable
Modifier and Type | Field and Description |
---|---|
protected DBCmdParamList |
cmdParamList |
protected DBMSHandler |
dbms |
protected StringBuilder |
sql |
protected static char |
TEXT_DELIMITER |
Modifier | Constructor and Description |
---|---|
protected |
DBSQLBuilder(DBMSHandler dbms)
Don't use this directly
Use dbms.createSQLBuilder()
|
Modifier and Type | Method and Description |
---|---|
DBSQLBuilder |
append(char c) |
DBSQLBuilder |
append(CharSequence sqlLiteral) |
DBSQLBuilder |
append(CharSequence sqlLiteral,
int start,
int end) |
void |
append(DBCommandExpr subQueryCmd) |
DBSQLBuilder |
append(DBSqlPhrase phrase) |
DBSQLBuilder |
append(double d) |
DBSQLBuilder |
append(long l) |
protected void |
appendSimpleValue(DataType type,
Object value)
Returns a sql string for a given value.
|
protected void |
appendStringLiteral(DataType type,
Object value)
encodes Text values for an SQL command string.
|
void |
appendTemplate(String template,
Object[] values,
DataType[] dataTypes,
long context,
String arraySep)
Expands an SQL template and adds it to the SQL command
|
void |
appendValue(DataType type,
Object value)
Appends the SQL representation of a value
|
void |
appendValue(DataType dataType,
Object value,
long context,
String arraySep)
Appends the SQL representation of a value
|
protected void |
escapeAndAppendLiteral(String value)
this helper function doubles up single quotes for SQL
|
protected String |
getDateTimeString(Object value,
DBSqlPhrase sqlTemplate,
DBSqlPhrase sqlPattern,
DBSqlPhrase sqlCurrentDate)
encodes a Date value for an SQL command string.
|
DBMSHandler |
getDbms() |
protected String |
getNumberString(Object value,
DataType type)
encodes a numeric value for an SQL command string.
|
String |
getPhrase(DBSqlPhrase phrase) |
int |
length() |
void |
reset(int pos) |
void |
setCmdParams(DBCmdParamList cmdParamList) |
protected boolean |
stringToBoolean(String value)
this function converts a string containing a boolean expression to a boolean.
|
String |
toString()
returns the SQL as a String
|
protected static final char TEXT_DELIMITER
protected final DBMSHandler dbms
protected final StringBuilder sql
protected DBCmdParamList cmdParamList
protected DBSQLBuilder(DBMSHandler dbms)
public void setCmdParams(DBCmdParamList cmdParamList)
public DBMSHandler getDbms()
public String getPhrase(DBSqlPhrase phrase)
public int length()
public void reset(int pos)
public DBSQLBuilder append(CharSequence sqlLiteral)
append
in interface Appendable
public DBSQLBuilder append(CharSequence sqlLiteral, int start, int end)
append
in interface Appendable
public DBSQLBuilder append(char c)
append
in interface Appendable
public DBSQLBuilder append(long l)
public DBSQLBuilder append(double d)
public DBSQLBuilder append(DBSqlPhrase phrase)
public void append(DBCommandExpr subQueryCmd)
public void appendValue(DataType type, Object value)
type
- the data typevalue
- an DBExpr object, array or a basis data type(e.g. int, String)public void appendValue(DataType dataType, Object value, long context, String arraySep)
dataType
- the DataTypevalue
- an DBExpr object, array or a basis data type(e.g. int, String)context
- the context of the DBColumnExpr objectarraySep
- the separator valuepublic void appendTemplate(String template, Object[] values, DataType[] dataTypes, long context, String arraySep)
template
- the SQL templatevalues
- list of values to be inserted into the templatedataTypes
- list of data typescontext
- the context of the DBColumnExpr objectarraySep
- the separator valueprotected void appendSimpleValue(DataType type, Object value)
type
- the data type of the supplied valuevalue
- the value which is inserted to the new Stringprotected String getDateTimeString(Object value, DBSqlPhrase sqlTemplate, DBSqlPhrase sqlPattern, DBSqlPhrase sqlCurrentDate)
value
- the value to encodesqlTemplate
- the templatesqlPattern
- the patternsqlCurrentDate
- the current date phraseprotected void appendStringLiteral(DataType type, Object value)
type
- date type (can only be TEXT, CHAR, CLOB and UNIQUEID)value
- the literal to be encodedprotected void escapeAndAppendLiteral(String value)
protected String getNumberString(Object value, DataType type)
value
- the numeric valuetype
- the number data typeprotected boolean stringToBoolean(String value)
value
- the string containing a boolean expressionCopyright © 2008–2023 Apache Software Foundation. All rights reserved.