StatementBuilder

A utility class to build a statement. In addition to the methods supported by StringBuilder, it allows to add a text only in the second iteration. This simplified constructs such as:
 StringBuilder buff = new StringBuilder();
 for (int i = 0; i < args.length; i++) {
     if (i > 0) {
         buff.append(", ");
     }
     buff.append(args[i]);
 }
to
 StatementBuilder buff = new StatementBuilder();
 for (String s : args) {
     buff.appendExceptFirst(", ");
     buff.append(a);
 }


Methods
StatementBuilder()
Create a new builder.
StatementBuilder()
Create a new builder.
StatementBuilder(String string)
Create a new builder.
StatementBuilder(String string)
Create a new builder.
Parameters:
string - the initial string
StatementBuilder append(String s)
Append a text.
StatementBuilder append(String s)
Append a text.
Parameters:
s - the text to append
Returns:
itself
StatementBuilder append(char c)
Append a character.
StatementBuilder append(char c)
Append a character.
Parameters:
c - the character to append
Returns:
itself
StatementBuilder append(long x)
Append a number.
StatementBuilder append(long x)
Append a number.
Parameters:
x - the number to append
Returns:
itself
void appendExceptFirst(String s)
Append a text, except when this method is called the first time.
void appendExceptFirst(String s)
Append a text, except when this method is called the first time.
Parameters:
s - the text to append
void appendOnlyFirst(String s)
Append a text, but only if appendExceptFirst was never called.
void appendOnlyFirst(String s)
Append a text, but only if appendExceptFirst was never called.
Parameters:
s - the text to append
int length()
Get the length.
int length()
Get the length.
Returns:
the length
StatementBuilder resetCount()
Reset the loop counter.
StatementBuilder resetCount()
Reset the loop counter.
Returns:
itself
String toString()
String toString()