An immutable sql statement string created from multiple tokens in order to write inline sql statements in an easy-to-read fashion spread out over multiple lines of code.
The class implements CharSequence and thus can be used as a drop-in
alternative wherever API supports CharSequence rather than String.
null or empty inputs are permitted (no run-time exceptions).Example:
String tblName = "table";
Sql.of("SELECT COUNT(*)",
"FROM", tblName,
" WHERE cond1 = :cond1",
" AND cond2 = :cond2");
| Modifier and Type | Field and Description |
|---|---|
| private static final Sql | |
| private final String | str
The internal sql string. |
| Modifier and Type | Method and Description |
|---|---|
| public char | charAt(int index)
Implements java. Returns the |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| pack-priv static String | Returns: formatted sql stringcollection of tokens tokens)Formats an sql statement from multiple tokens. |
| public int | |
| public int | |
| public static Sql | |
| public static Sql | |
| public CharSequence | subSequence(int start, int end)
Implements java. Returns a |
| public String | toString()
Overrides java. Implements java. Returns a string containing the characters in this sequence in the same order as this sequence. |
| EMPTY_SQL | back to summary |
|---|---|
| private static final Sql EMPTY_SQL | |
| str | back to summary |
|---|---|
| private final String str The internal sql string. Cannot be null. | |
| Sql | back to summary |
|---|---|
| private Sql(String sql) | |
| charAt | back to summary |
|---|---|
| public char charAt(int index) Implements java. Doc from java. Returns the If the
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| format | back to summary |
|---|---|
| pack-priv static String format(Iterable<? extends CharSequence> tokens) Formats an sql statement from multiple tokens.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| length | back to summary |
|---|---|
| public int length() Implements java. Doc from java. Returns the length of this character sequence. The length is the number
of 16-bit
| |
| of | back to summary |
|---|---|
| public static Sql of(CharSequence... tokens) | |
| of | back to summary |
|---|---|
| public static Sql of(Iterable<? extends CharSequence> tokens) | |
| subSequence | back to summary |
|---|---|
| public CharSequence subSequence(int start, int end) Implements java. Doc from java. Returns a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Doc from java. Returns a string containing the characters in this sequence in the same order as this sequence. The length of the string will be the length of this sequence.
| |