com.primix.tapestry.util.jdbc
Class StatementAssembly

java.lang.Object
  |
  +--com.primix.tapestry.util.jdbc.StatementAssembly

public class StatementAssembly
extends java.lang.Object

Class for creating and executing JDBC statements.

Version:
$Id: StatementAssembly.java,v 1.7 2001/05/02 14:15:17 hship Exp $
Author:
Howard Ship

Constructor Summary
StatementAssembly()
          Default constructor; uses a maximum line length of 80 and an indent of 5.
StatementAssembly(int maxLineLength, int indent)
           
 
Method Summary
 void add(boolean value)
          Adds a boolean value as either '0' or '1'.
 void add(double value)
           
 void add(float value)
           
 void add(int value)
           
 void add(long value)
           
 void add(java.lang.Object value)
          Adds an arbitrary object to the SQL by invoking Object.toString().
 void add(short value)
           
 void add(java.lang.String text)
          Adds text to the current line, unless that would make the line too long, in which case a new line is started (and indented) before adding the text.
 void addList(int[] items, java.lang.String seperator)
           
 void addList(java.lang.Object[] items, java.lang.String seperator)
           
 void addList(java.lang.String[] items, java.lang.String seperator)
           
 void addParameter(java.lang.Object value)
          Adds a parameter to the statement.
 void addParameter(java.lang.String text, java.lang.Object value)
          Adds a parameter with some associated text, which should include the question mark used to represent the parameter in the SQL.
 void addSep(java.lang.String text)
          Adds a seperator (usually a comma and a space) to the current line, regardless of line length.
 IStatement createStatement(java.sql.Connection connection)
          Creates and returns a IStatement based on the SQL and parameters acquired.
 int getIndent()
          Number of spaces to indent continuation lines by.
 int getMaxLineLength()
          Maximum length of a line.
 void newLine()
          Starts a new line, without indenting.
 void newLine(java.lang.String text)
          Starts a new line, then adds the given text.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatementAssembly

public StatementAssembly()
Default constructor; uses a maximum line length of 80 and an indent of 5.

StatementAssembly

public StatementAssembly(int maxLineLength,
                         int indent)
Method Detail

getMaxLineLength

public int getMaxLineLength()
Maximum length of a line.

getIndent

public int getIndent()
Number of spaces to indent continuation lines by.

add

public void add(java.lang.String text)
Adds text to the current line, unless that would make the line too long, in which case a new line is started (and indented) before adding the text.

Text is added as-is, with no concept of quoting. To add arbitrary strings (such as in a where clause), use addParameter().


add

public void add(int value)
Since:
0.2.10

add

public void add(short value)
Since:
0.2.10

add

public void add(float value)
Since:
0.2.10

add

public void add(double value)
Since:
0.2.10

add

public void add(long value)
Since:
0.2.10

add

public void add(java.lang.Object value)
Adds an arbitrary object to the SQL by invoking Object.toString(). This is typically used with Integer, Double, etc. Note that this will not work well with Boolean ... invoke add(boolean) instead.
Since:
0.2.10

add

public void add(boolean value)
Adds a boolean value as either '0' or '1'.
Since:
0.2.10

addSep

public void addSep(java.lang.String text)
Adds a seperator (usually a comma and a space) to the current line, regardless of line length. "this is purely aesthetic ... it just looks odd if a seperator gets wrapped to a new line by itself.

newLine

public void newLine()
Starts a new line, without indenting.

newLine

public void newLine(java.lang.String text)
Starts a new line, then adds the given text.

addList

public void addList(java.lang.String[] items,
                    java.lang.String seperator)

addList

public void addList(java.lang.Object[] items,
                    java.lang.String seperator)
Since:
0.2.10

addList

public void addList(int[] items,
                    java.lang.String seperator)
Since:
0.2.10

addParameter

public void addParameter(java.lang.Object value)
Adds a parameter to the statement. Adds a question mark to the SQL and stores the value for later.

addParameter

public void addParameter(java.lang.String text,
                         java.lang.Object value)
Adds a parameter with some associated text, which should include the question mark used to represent the parameter in the SQL.

createStatement

public IStatement createStatement(java.sql.Connection connection)
                           throws java.sql.SQLException
Creates and returns a IStatement based on the SQL and parameters acquired.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object