org.makumba.list.engine
Class QueryExecution

java.lang.Object
  extended by org.makumba.list.engine.QueryExecution

public class QueryExecution
extends Object

This class holds the listData of a mak:list or the valueQuery data of a mak:value. It determines iterationGroups at every parentIteration, and iterates through the iterationGroupData

Version:
$Id: QueryExecution.java 5151 2010-05-18 19:07:27Z rosso_nero $
Author:
Cristian Bogdan

Field Summary
(package private)  Stack<Dictionary<String,Object>> currentDataSet
          A reference to the currentDataSet shared by all ListQueryExecutions in the listGroup
 int iteration
          The index of iteration within the iteration group
(package private)  Vector<ArrayMap> iterationGroupData
          The part of listData iterated for a certain parent iteration
(package private)  Grouper listData
          The results of the query associated with the list or queryMak:value
 HashMap<MultipleKey,Object> valueQueryData
          Stores the data for queryData
 
Method Summary
static int computeLimit(PageContext pc, String s, int defaultValue, int defaultNonSpecified)
          Computes the limit from the value passed in the limit tag parameter.
 ArrayMap currentListData()
          Returns the data of the current iteration
 int dataSize()
          Computes the size of the iterationGroupData
 void endIterationGroup()
          Pops the the last data of an iterationGroup.
static void endListGroup(PageContext pageContext)
          De-allocates all QueryExecutions in the listGroup, and the currentDataSet.
static QueryExecution getFor(MultipleKey key, PageContext pageContext, String offset, String limit)
          Gets the QueryExecution for the given key, builds one if needed.
static QueryExecution getFor(MultipleKey key, PageContext pageContext, String offset, String limit, String defaultLimit)
          Like getFor(MultipleKey, PageContext, String, String), but uses the default values for offset/limit from the list tag.
 int getIterationGroupData()
          Gets the iterationGroupData from the listData
 boolean hasValueChanged(int projectionIndex)
           
 int nextGroupIteration()
          Pops the previous currentListData from the currentDataSet and checks if there are more iterations to be made within the iterationGroup.
 int onParentIteration()
          Computes the iterationGroupData based on listData and currentDataSet.
static void startListGroup(PageContext pageContext)
          Allocates a currentDataSet and a container for the QueryExecutions of the listGroup.
 boolean willValueChange(int projectionIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listData

Grouper listData
The results of the query associated with the list or queryMak:value


iterationGroupData

Vector<ArrayMap> iterationGroupData
The part of listData iterated for a certain parent iteration


iteration

public int iteration
The index of iteration within the iteration group


currentDataSet

Stack<Dictionary<String,Object>> currentDataSet
A reference to the currentDataSet shared by all ListQueryExecutions in the listGroup


valueQueryData

public HashMap<MultipleKey,Object> valueQueryData
Stores the data for queryData

Method Detail

startListGroup

public static void startListGroup(PageContext pageContext)
Allocates a currentDataSet and a container for the QueryExecutions of the listGroup. Executed by the rootList.

Parameters:
pageContext - The PageContext object of the current page

endListGroup

public static void endListGroup(PageContext pageContext)
De-allocates all QueryExecutions in the listGroup, and the currentDataSet. Executed by the rootList.

Parameters:
pageContext - The PageContext object of the current page

getFor

public static QueryExecution getFor(MultipleKey key,
                                    PageContext pageContext,
                                    String offset,
                                    String limit)
                             throws LogicException
Gets the QueryExecution for the given key, builds one if needed. Every list tag (QueryTag) calls this method. A ListQueryTag will be built only in the first parentIteration and will be returned at next parentIterations.

Parameters:
key - The tag key of the tag calling the QueryExecution
pageContext - The PageContext object of the current page
offset - Offset at which the iteration should start
limit - Limit at which the iteration should stop
Throws:
LogicException

getFor

public static QueryExecution getFor(MultipleKey key,
                                    PageContext pageContext,
                                    String offset,
                                    String limit,
                                    String defaultLimit)
                             throws LogicException
Like getFor(MultipleKey, PageContext, String, String), but uses the default values for offset/limit from the list tag.

Throws:
LogicException

computeLimit

public static int computeLimit(PageContext pc,
                               String s,
                               int defaultValue,
                               int defaultNonSpecified)
                        throws LogicException
Computes the limit from the value passed in the limit tag parameter.

Parameters:
pc - The PageContext object of the current page
s - The parameter value passed
defaultNonSpecified - The default value of the limit/offset if the attribute is not specified in the list tag
defaultValue - The fault value of the limit/offset if the attribute is specified in the list tag, but not present as attribute
Returns:
The int value of the limit, if a correct one is passed as tag parameter
Throws:
LogicException

getIterationGroupData

public int getIterationGroupData()
Gets the iterationGroupData from the listData

Returns:
The size of the current iterationGroupData
See Also:
iterationGroupData, listData

dataSize

public int dataSize()
Computes the size of the iterationGroupData

Returns:
The int value of the current iterationGroupData size

onParentIteration

public int onParentIteration()
Computes the iterationGroupData based on listData and currentDataSet. Pushes the first currentListData to the currentDataSet. Only if the dataSize is 0, nothing is pushed to the stack, and at endIterationGroup, nothing is popped.

Returns:
The number of iterations in the iterationGroup, possibly 0.

nextGroupIteration

public int nextGroupIteration()
Pops the previous currentListData from the currentDataSet and checks if there are more iterations to be made within the iterationGroup. If there are, adds the currentListData to the currentDataSet; else pushes a DUMMY data (cfr bug 555).

Returns:
The current iteration position, relative to the start of the interationGroup or -1 if there are no more results

endIterationGroup

public void endIterationGroup()
Pops the the last data of an iterationGroup. In case of an empty-body/simple QueryTag, this will pop the first element; otherwise it pops the dummy data. cfr Bug 555.


currentListData

public ArrayMap currentListData()
Returns the data of the current iteration

Returns:
The current listData

hasValueChanged

public boolean hasValueChanged(int projectionIndex)

willValueChange

public boolean willValueChange(int projectionIndex)