butler.sql.query
Class ScrollQuery

java.lang.Object
  extended by butler.sql.query.Query
      extended by butler.sql.query.ScrollQuery
All Implemented Interfaces:
Joinable, java.lang.Cloneable

public class ScrollQuery
extends Query

Scrollable query. This means that the query returns a maximum number of records, and uses a record as start record. This query should be used by client that can't show a infinite number of queries. The client is supposed to have "Page down" and "Page up" functions which uses this query. This query takes another query and modifies the where-clause and order by so scroll functionality is possible. If the original query has no sort criterias, the primary key will be used. If it has, the sort criteria must be unique.

Author:
Fredrik Bertilsson

Field Summary
 
Fields inherited from class butler.sql.query.Query
_cols, _comparator, _filter, _maxNoOfRec, _name, _table, _uniqueSort
 
Constructor Summary
ScrollQuery(Query nestedQuery, boolean down, int maxNo, boolean first)
           
 
Method Summary
 void addColumn(Column col)
          Adds a column to retrieve.
 QueryInstance createInstance()
          Creates a instance of this query.
 java.util.List getColumns()
          Returns a list of the columns to retrieve.
 RecordComparator getComparator()
           
 Join getJoinByAlias(java.lang.String alias)
           
 java.util.List getJoins()
          Returns the joins for this query.
 java.lang.String getName()
          Returns the query name.
 ScrollFilter getScrollFilter()
           
 Table getTable()
           
 Join join(ForeignKey fk)
          Joins another table to this query by a given foreign key.
 Join join(Table table)
          Joins another table to this query by a given table.
 java.util.Iterator newIterator(java.sql.ResultSet rs)
           
 Join outerJoin(ForeignKey fk)
          Joins another table to this query by a given foreign key, using left outer join.
 Join outerJoin(Table table)
          Joins another table to this query by a given table, using left outer join.
static ScrollQuery parseScrollQuery(org.dom4j.Element element)
           
protected  void registerJoin(java.lang.String alias, Join join)
           
 void setAscending(boolean asc)
           
 void setFilter(Filter filter)
          Sets the filter (where-clause).
 void setName(java.lang.String name)
          Sets the query name
 void toXML(org.xml.sax.ContentHandler handler)
           
 
Methods inherited from class butler.sql.query.Query
addColumn, addFunctionColumn, addSortCriteria, addSortCriteria, addSortCriteria, addSortCriteria, addSubQuery, checkPermission, copy, createTableDictonary, getColumn, getFilter, getFilter, getHaving, getMainTable, getMaxNoOfRecords, getPhysicalColumns, getSortCriterias, getSQL, getSubQueries, getUnions, is2D, isNested, isUnion, isUniqueSort, join, join, modifyFilter, newIterator, outerJoin, parse, parse, parseQuery, recursiveJoin, run, setAggregate, setAlias, setDistinct, setHaving, setMaxNoOfRecords, setNested, setRecordComparator, setSortCriterias, setUnion, setUniqueSort, toXML, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScrollQuery

public ScrollQuery(Query nestedQuery,
                   boolean down,
                   int maxNo,
                   boolean first)
            throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

setAscending

public void setAscending(boolean asc)

getScrollFilter

public ScrollFilter getScrollFilter()

setName

public void setName(java.lang.String name)
Sets the query name

Overrides:
setName in class Query

getName

public java.lang.String getName()
Returns the query name.

Overrides:
getName in class Query

addColumn

public void addColumn(Column col)
Adds a column to retrieve.

Overrides:
addColumn in class Query

getColumns

public java.util.List getColumns()
Returns a list of the columns to retrieve.

Overrides:
getColumns in class Query

setFilter

public void setFilter(Filter filter)
               throws java.lang.Exception
Sets the filter (where-clause).

Overrides:
setFilter in class Query
Throws:
java.lang.Exception

join

public Join join(ForeignKey fk)
          throws java.lang.Exception
Joins another table to this query by a given foreign key. Returns the resulting join.

Specified by:
join in interface Joinable
Overrides:
join in class Query
Throws:
java.lang.Exception

outerJoin

public Join outerJoin(ForeignKey fk)
               throws java.lang.Exception
Joins another table to this query by a given foreign key, using left outer join. Returns the resulting join.

Specified by:
outerJoin in interface Joinable
Overrides:
outerJoin in class Query
Throws:
java.lang.Exception

join

public Join join(Table table)
          throws java.lang.Exception
Joins another table to this query by a given table. If there are more than one foreign keys between the main table and this, an exception will occur. Returns the resulting join.

Overrides:
join in class Query
Throws:
java.lang.Exception

outerJoin

public Join outerJoin(Table table)
               throws java.lang.Exception
Joins another table to this query by a given table, using left outer join. If there are more than one foreign keys between the main table and this, an exception will occur. Returns the resulting join.

Overrides:
outerJoin in class Query
Throws:
java.lang.Exception

getJoins

public java.util.List getJoins()
Returns the joins for this query.

Overrides:
getJoins in class Query

createInstance

public QueryInstance createInstance()
Creates a instance of this query.

Overrides:
createInstance in class Query

getTable

public Table getTable()
Overrides:
getTable in class Query

getJoinByAlias

public Join getJoinByAlias(java.lang.String alias)
Overrides:
getJoinByAlias in class Query

registerJoin

protected void registerJoin(java.lang.String alias,
                            Join join)
Overrides:
registerJoin in class Query

getComparator

public RecordComparator getComparator()
                               throws java.lang.Exception
Overrides:
getComparator in class Query
Throws:
java.lang.Exception

newIterator

public java.util.Iterator newIterator(java.sql.ResultSet rs)
                               throws java.lang.Exception
Throws:
java.lang.Exception

toXML

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

parseScrollQuery

public static ScrollQuery parseScrollQuery(org.dom4j.Element element)
                                    throws java.lang.Exception
Throws:
java.lang.Exception