org.deegree.observation.persistence
Class QueryBuilder

java.lang.Object
  extended by org.deegree.observation.persistence.QueryBuilder

public class QueryBuilder
extends Object

This is a simple builder for prepared statements.

Version:
$Revision: 24362 $, $Date: 2010-05-12 15:42:07 +0200 (Wed, 12 May 2010) $
Author:
Oliver Tonnhofer, last edited by: $Author: aionita $

Nested Class Summary
static interface QueryBuilder.SetObject
          This interface is used to set objects into prepared statements.
 
Constructor Summary
QueryBuilder()
           
 
Method Summary
 QueryBuilder add(QueryBuilder.SetObject setter)
          Add a new object setter.
 QueryBuilder add(String stmt)
          Add a new part to the statement.
 PreparedStatement buildStatement(Connection conn)
          Create a prepared statment with all parameter set.
static QueryBuilder.SetObject stringSetter(String value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryBuilder

public QueryBuilder()
Method Detail

add

public QueryBuilder add(String stmt)
Add a new part to the statement. For each '?' wildcard in the statement string you must call add(SetObject). It will append whitespace to separate tokens.

Parameters:
stmt - the part of the query
Returns:
this for method chaining

add

public QueryBuilder add(QueryBuilder.SetObject setter)
Add a new object setter. You must add one setter for each parameter (?) in the query.

Parameters:
setter -
Returns:
this for method chaining

buildStatement

public PreparedStatement buildStatement(Connection conn)
                                 throws SQLException
Create a prepared statment with all parameter set.

Parameters:
conn -
Returns:
the prepared statement
Throws:
SQLException

toString

public String toString()
Overrides:
toString in class Object

stringSetter

public static QueryBuilder.SetObject stringSetter(String value)
Parameters:
value - the string to set
Returns:
a SetObject that sets a String


Copyright © 2011. All Rights Reserved.