|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.almworks.sqlite4java.SQLParts
public final class SQLParts
SQLParts is a means to avoid excessive garbage production during String concatenation when SQL is constructed.
Often, same SQL statements get constructed over and over again and passed to SQLiteConnecton.prepare.
To avoid producing garbage and to facilitate quick look-up in the cache of prepared statements, better use SQLParts
than String concatenation.
SQLParts object may be fixed, which means it cannot be changed anymore.
This class is not thread-safe and not intended to be used from different threads.
| Constructor Summary | |
|---|---|
SQLParts()
Create empty SQLParts object. |
|
SQLParts(SQLParts copyFrom)
Create a copy of another SQLParts object. |
|
SQLParts(java.lang.String sql)
Create an instance of SQLParts containing only single piece of SQL. |
|
| Method Summary | |
|---|---|
SQLParts |
append(SQLParts parts)
Adds all parts from a different SQLParts to the SQL. |
SQLParts |
append(java.lang.String part)
Adds a part to the SQL. |
SQLParts |
appendParams(int count)
Appends an SQL part consisting of a list of bind parameters. |
void |
clear()
Empties this SQLParts instance. |
boolean |
equals(java.lang.Object o)
|
SQLParts |
fix()
Makes instance immutable. |
SQLParts |
getFixedParts()
If this object is fixed, returns itself, otherwise returns a fixed copy of this object. |
java.util.List<java.lang.String> |
getParts()
Gets the list of SQL parts. |
int |
hashCode()
|
boolean |
isFixed()
Checks if this instance is fixed. |
java.lang.String |
toString()
Returns the SQL representation of this params |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SQLParts()
public SQLParts(SQLParts copyFrom)
copyFrom - the original objectpublic SQLParts(java.lang.String sql)
sql - SQL piece| Method Detail |
|---|
public SQLParts fix()
append(java.lang.String) will throw an exception.
public SQLParts getFixedParts()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic void clear()
java.lang.IllegalStateException - if instance is fixedpublic SQLParts append(java.lang.String part)
part - a piece of SQL added
java.lang.IllegalStateException - if instance is fixedpublic SQLParts append(SQLParts parts)
parts - source object to copy parts from, may be null
java.lang.IllegalStateException - if instance is fixedpublic SQLParts appendParams(int count)
That is, appendParams(1) appends ?, appendParams(2)
appends ?,? and so on.
count - the number of parameters ("?" symbols) to be added
java.lang.IllegalStateException - if instance is fixedpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<java.lang.String> getParts()
public boolean isFixed()
fix()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||