Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.solarmetric.kodo.impl.jdbc.sql
Class SQLBuffer

    java.lang.Object
      |
      +--com.solarmetric.kodo.impl.jdbc.sql.SQLBuffer

All Implemented Interfaces:
  Serializable

public final class SQLBuffer
extends Object
implements Serializable

Buffer for SQL statements. A SQLBuffer holds a list of `SQLElement` objects, which will be concatinated to build a meaningful SQL representation. The SQL that is held in a SQLBuffer is not datastore-agnostic. The `SQLElement` implementations that are added to the list are arbitrary, but typically values that will not usefully be parameterized by the data store will be added as `SQLLiteral`s, and values that can be parameterized will be added as `SQLValue`s. This allows the runtime envionment to be able to re-use existing `PreparedStatement` objects with a high cache hit ratio, while still maintaining meaningful parameterization of the SQL statements.

Raw SQL suitable for use in a `Statement` can always be accessed via the getStatementSQL method.

Example usage:

    	SQLBuffer query = new SQLBuffer ();
    	query.appendLiteral ("SELECT * FROM MYTABLE ");

    	SQLBuffer whereClause = new SQLBuffer ();
    	whereClause.appendLiteral ("WHERE ID = ");
    	whereClause.appendValue (new SQLValue (new Integer (10), dict, type));

    	query.appendBuffer (whereClause);

    	String selectSQL = query.getStatementSQL ();

This class is not thread-safe.

Since:
  2.4
See Also:
  `SQLValue`, `SQLLiteral`, `SQLElement`, Serialized Form

Field Summary
`(package private) List` | `sql`

Constructor Summary
`SQLBuffer()` Constructor.
`SQLBuffer(SQLBuffer toCopy)` Constructor.
`SQLBuffer(String rawSQL)` Constructor.

Method Summary
`SQLBuffer` | `appendBuffer(SQLBuffer buffer)` Append all elements of the specified SQLBuffer (shallowly) to this one.
`SQLBuffer` | `appendLiteral(SQLLiteral literal)` Append some raw, un-preparable SQL to the statement.
`SQLBuffer` | `appendLiteral(String rawSQL)` Append some raw, un-preparable SQL to the statement.
`SQLBuffer` | `appendValue(SQLValue element)` Append a SQLValue.
`Object` | `clone()` Perform a shallow clone of this SQL Buffer.
`boolean` | `equals(Object other)`
`String` | `getPreparedStatementSQL()` Obtain the String key can can be used to look up an equivalent PreparedStatement in a Map of String:PreparedStatement.
`String` | `getStatementSQL()` Obtain the raw SQL that can be used in a Statement.
`int` | `hashCode()`
`Iterator` | `iterator()` Obtain an interator the the list of SQL Statements.
`int` | `setParameters(PreparedStatement ps)` Populate the parameters of an existing PreparedStatement with values from this SQLBuffer.
`int` | `setParameters(PreparedStatement ps, int startIndex)` Populate the parameters of an existing PreparedStatement with values from this SQLBuffer.
`int` | `size()` Returns the number of SQLElements contained in this buffer.

Methods inherited from class java.lang.Object
`, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### sql

    final List sql

Constructor Detail

### SQLBuffer

    public SQLBuffer()

  Constructor. Create an empty SQLBuffer.

### SQLBuffer

    public SQLBuffer(String rawSQL)

  Constructor. Create a SQLBuffer with the first element being the specified raw SQL String.

### SQLBuffer

    public SQLBuffer(SQLBuffer toCopy)

  Constructor. Create a new SQLBuffer using a shallow clone of the specified buffer.

Method Detail

### clone

    public Object clone()

  Perform a shallow clone of this SQL Buffer.
  Overrides:
    `clone` in class `Object`

### appendLiteral

    public SQLBuffer appendLiteral(String rawSQL)

  Append some raw, un-preparable SQL to the statement.

### appendLiteral

    public SQLBuffer appendLiteral(SQLLiteral literal)

  Append some raw, un-preparable SQL to the statement.

### appendValue

    public SQLBuffer appendValue(SQLValue element)

  Append a SQLValue.

### appendBuffer

    public SQLBuffer appendBuffer(SQLBuffer buffer)

  Append all elements of the specified SQLBuffer (shallowly) to this one.

### getPreparedStatementSQL

    public String getPreparedStatementSQL()

  Obtain the String key can can be used to look up an equivalent PreparedStatement in a Map of String:PreparedStatement.

### getStatementSQL

    public String getStatementSQL()

  Obtain the raw SQL that can be used in a Statement.

### setParameters

    public int setParameters(PreparedStatement ps)
                      throws SQLException

  Populate the parameters of an existing PreparedStatement with values from this SQLBuffer.

### setParameters

    public int setParameters(PreparedStatement ps,
                             int startIndex)
                      throws SQLException

  Populate the parameters of an existing PreparedStatement with values from this SQLBuffer.

### size

    public int size()

  Returns the number of SQLElements contained in this buffer.

### iterator

    public Iterator iterator()

  Obtain an interator the the list of SQL Statements.

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object other)

  Overrides:
    `equals` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.