public final class SQLBuffer
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Constructor and Description |
---|
SQLBuffer(DBDictionary dict)
Default constructor.
|
SQLBuffer(SQLBuffer buf)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addCastForParam(java.lang.String oper,
Val val)
Replace SQL '?' with CAST string if required by DB platform
|
SQLBuffer |
append(Column col) |
SQLBuffer |
append(DBIdentifier name) |
SQLBuffer |
append(Select sel,
JDBCFetchConfiguration fetch)
Append a subselect.
|
SQLBuffer |
append(Sequence seq) |
SQLBuffer |
append(SQLBuffer buf)
Append all SQL and parameters of the given buffer.
|
SQLBuffer |
append(java.lang.String s) |
SQLBuffer |
append(Table table) |
SQLBuffer |
appendCount(Select sel,
JDBCFetchConfiguration fetch)
Append a subselect count.
|
SQLBuffer |
appendValue(boolean b)
Append a parameter value.
|
SQLBuffer |
appendValue(boolean b,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(byte b)
Append a parameter value.
|
SQLBuffer |
appendValue(byte b,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(char c)
Append a parameter value.
|
SQLBuffer |
appendValue(char c,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(double d)
Append a parameter value.
|
SQLBuffer |
appendValue(double d,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(float f)
Append a parameter value.
|
SQLBuffer |
appendValue(float f,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(int i)
Append a parameter value.
|
SQLBuffer |
appendValue(int i,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(long l)
Append a parameter value.
|
SQLBuffer |
appendValue(long l,
Column col)
Append a parameter value.
|
SQLBuffer |
appendValue(java.lang.Object o)
Append a parameter value.
|
SQLBuffer |
appendValue(java.lang.Object o,
Column col)
Append a system inserted parameter value for a specific column.
|
SQLBuffer |
appendValue(java.lang.Object o,
Column col,
Parameter userParam)
Append a user parameter value for a specific column.
|
SQLBuffer |
appendValue(short s)
Append a parameter value.
|
SQLBuffer |
appendValue(short s,
Column col)
Append a parameter value.
|
java.lang.Object |
clone()
Perform a shallow clone of this SQL Buffer.
|
boolean |
equals(java.lang.Object other) |
java.util.List |
getColumns() |
java.util.List |
getParameters()
Return the list of parameter values.
|
java.lang.String |
getSQL()
Return the SQL for this buffer.
|
java.lang.String |
getSQL(boolean replaceParams)
Returns the SQL for this buffer.
|
java.util.List |
getUserParameters()
Get the user parameter positions in the list of parameters.
|
int |
hashCode() |
boolean |
isEmpty()
Return true if the buffer is emtpy.
|
java.sql.CallableStatement |
prepareCall(java.sql.Connection conn)
Create and populate the parameters of a prepared statement using
the SQL in this buffer.
|
java.sql.CallableStatement |
prepareCall(java.sql.Connection conn,
int rsType,
int rsConcur)
Create and populate the parameters of a prepared statement using
the SQL in this buffer.
|
java.sql.CallableStatement |
prepareCall(java.sql.Connection conn,
JDBCFetchConfiguration fetch,
int rsType,
int rsConcur)
Create and populate the parameters of a prepred statement using the
SQL in this buffer and the given fetch configuration.
|
java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn)
Create and populate the parameters of a prepared statement using
the SQL in this buffer.
|
java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn,
int rsType,
int rsConcur)
Create and populate the parameters of a prepared statement using
the SQL in this buffer.
|
java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn,
JDBCFetchConfiguration fetch,
int rsType,
int rsConcur)
Create and populate the parameters of a prepred statement using the
SQL in this buffer and the given fetch configuration.
|
boolean |
replace(Select old,
Select sel)
Replace a subselect.
|
void |
replaceSqlString(int start,
int end,
java.lang.String newString)
Replace current buffer string with the new string
|
void |
setParameters(java.util.List params) |
void |
setParameters(java.sql.PreparedStatement ps)
Populate the parameters of an existing PreparedStatement
with values from this buffer.
|
boolean |
sqlEquals(java.lang.String sql)
Compare internal SQL without resolving subselects or stringifying
parameters.
|
public SQLBuffer(DBDictionary dict)
public SQLBuffer(SQLBuffer buf)
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean isEmpty()
public SQLBuffer append(DBIdentifier name)
public SQLBuffer append(java.lang.String s)
public SQLBuffer append(Select sel, JDBCFetchConfiguration fetch)
public SQLBuffer appendCount(Select sel, JDBCFetchConfiguration fetch)
public SQLBuffer appendValue(java.lang.Object o)
public SQLBuffer appendValue(java.lang.Object o, Column col)
public SQLBuffer appendValue(java.lang.Object o, Column col, Parameter userParam)
userParam
- if non-null, designates a 'user' parameter.public SQLBuffer appendValue(boolean b)
public SQLBuffer appendValue(byte b)
public SQLBuffer appendValue(char c)
public SQLBuffer appendValue(double d)
public SQLBuffer appendValue(float f)
public SQLBuffer appendValue(int i)
public SQLBuffer appendValue(long l)
public SQLBuffer appendValue(short s)
public java.util.List getParameters()
public java.util.List getUserParameters()
getParameters()
list. The even element
of the returned list refers to the user parameter key.
This structure is preferred over a normal map because a user parameter
may occur more than one in the parameters.public java.lang.String getSQL()
public java.lang.String getSQL(boolean replaceParams)
replaceParams
- if true, then replace parameters with the
actual parameter valuespublic java.sql.PreparedStatement prepareStatement(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, int rsType, int rsConcur) throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, JDBCFetchConfiguration fetch, int rsType, int rsConcur) throws java.sql.SQLException
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.sql.Connection conn, int rsType, int rsConcur) throws java.sql.SQLException
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.sql.Connection conn, JDBCFetchConfiguration fetch, int rsType, int rsConcur) throws java.sql.SQLException
java.sql.SQLException
public void setParameters(java.sql.PreparedStatement ps) throws java.sql.SQLException
java.sql.SQLException
public int hashCode()
hashCode
in class java.lang.Object
public boolean sqlEquals(java.lang.String sql)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public void addCastForParam(java.lang.String oper, Val val)
oper
- val
- public void replaceSqlString(int start, int end, java.lang.String newString)
start
- replace start positionend
- replace end positionnewString
- public void setParameters(java.util.List params)
public java.util.List getColumns()