butler.sql.query
Class QueryInstance

java.lang.Object
  extended by butler.sql.query.QueryInstance
All Implemented Interfaces:
Populatable
Direct Known Subclasses:
DeleteQuery.DeleteQueryInstance

public class QueryInstance
extends java.lang.Object
implements Populatable

A instance of a query. A query represents a SQL statement without parameters and a query instance represents a SQL statement plus parameters.

Author:
Fredrik Bertilsson

Field Summary
protected  Query _query
           
 
Constructor Summary
QueryInstance()
           
QueryInstance(Query query)
           
QueryInstance(java.lang.String xml)
          Constructs a QueryInstance from the xml representation.
 
Method Summary
 void addParameter(java.lang.Object param)
           
protected  void close(JPreparedStatement stmt)
           
 java.util.List getParamList()
           
 java.util.List getParamList(Filter filter)
           
 Query getQuery()
           
 QueryParams getQueryParams()
           
static QueryInstance parse(java.lang.String xml)
           
static QueryInstance parseQueryInstance(org.dom4j.Element element)
           
protected  JPreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String sql)
           
 RecordList run()
          Executes the SQL statement and returns the result as a RecordList.
 RecordList run0()
           
 void setParameter(Filter filter, java.util.List params)
          Sets a number of parameters for the given filter.
 void setParameter(Filter filter, java.lang.Object param)
           
 void setQueryParams(QueryParams params)
           
 java.lang.String toXML()
           
 void toXML(org.xml.sax.ContentHandler handler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_query

protected Query _query
Constructor Detail

QueryInstance

public QueryInstance(Query query)

QueryInstance

public QueryInstance()

QueryInstance

public QueryInstance(java.lang.String xml)
              throws java.lang.Exception
Constructs a QueryInstance from the xml representation.

Throws:
java.lang.Exception
Method Detail

setQueryParams

public void setQueryParams(QueryParams params)

setParameter

public void setParameter(Filter filter,
                         java.util.List params)
                  throws java.lang.Exception
Sets a number of parameters for the given filter.

Specified by:
setParameter in interface Populatable
Throws:
java.lang.Exception

setParameter

public void setParameter(Filter filter,
                         java.lang.Object param)
                  throws java.lang.Exception
Throws:
java.lang.Exception

addParameter

public void addParameter(java.lang.Object param)

run

public RecordList run()
               throws java.lang.Exception
Executes the SQL statement and returns the result as a RecordList.

Throws:
java.lang.Exception

run0

public RecordList run0()
                throws java.lang.Exception
Throws:
java.lang.Exception

getParamList

public java.util.List getParamList()
                            throws java.lang.Exception
Throws:
java.lang.Exception

getParamList

public java.util.List getParamList(Filter filter)
                            throws java.lang.Exception
Throws:
java.lang.Exception

getQueryParams

public QueryParams getQueryParams()

close

protected void close(JPreparedStatement stmt)

prepareStatement

protected JPreparedStatement prepareStatement(java.sql.Connection conn,
                                              java.lang.String sql)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getQuery

public Query getQuery()

toXML

public java.lang.String toXML()
                       throws java.lang.Exception
Throws:
java.lang.Exception

toXML

public void toXML(org.xml.sax.ContentHandler handler)
           throws java.lang.Exception
Throws:
java.lang.Exception

parse

public static QueryInstance parse(java.lang.String xml)
                           throws java.lang.Exception
Throws:
java.lang.Exception

parseQueryInstance

public static QueryInstance parseQueryInstance(org.dom4j.Element element)
                                        throws java.lang.Exception
Throws:
java.lang.Exception