jimm.datavision.source.sql
Class SubreportQuery

java.lang.Object
  extended by jimm.datavision.source.Query
      extended by jimm.datavision.source.sql.SQLQuery
          extended by jimm.datavision.source.sql.SubreportQuery
All Implemented Interfaces:
Writeable

public class SubreportQuery
extends SQLQuery

Queries build SQL query strings. They contain tables, joins, and where clauses.

Author:
Jim Menard, jimm@io.com
See Also:
ParserHelper

Field Summary
protected  Subreport subreport
           
protected  java.util.ArrayList subreportJoins
           
 
Fields inherited from class jimm.datavision.source.sql.SQLQuery
preparedStmtValues, tables
 
Fields inherited from class jimm.datavision.source.Query
joins, report, selectables, SORT_ASCENDING, SORT_DESCENDING, SORT_UNDEFINED, sortOrders, sortSelectables, whereClause
 
Constructor Summary
SubreportQuery(Subreport report)
          Constructor.
 
Method Summary
 void addSubreportJoin(Join join)
           
 void addSubreportJoins(java.util.Collection coll)
           
protected  void buildWhereClause(java.lang.StringBuffer str, boolean forDisplay)
           
 java.lang.String getWhereClauseForDisplay()
          Returns the where clause string; may be null.
 java.lang.String getWhereClauseForPreparedStatement()
          Returns the where clause string; may be null.
 java.util.Iterator parentColumns()
          Returns an iterator over all of the columns that need to be included in the parent report's query so that the values are available to this subreport when it builds its query.
 void setParameters(java.sql.PreparedStatement stmt)
          Given a prepared statement created with the text returned by toPreparedStatementString, plug in all the parameter and formula values.
protected  void writeExtras(XMLWriter out)
          This method exists so subclasses can write out extra information.
 
Methods inherited from class jimm.datavision.source.sql.SQLQuery
addParameter, addParameterForDisplay, addTable, buildFrom, buildJoins, buildOrderBy, buildSelect, buildUserWhereClause, findSelectablesUsed, getNumTables, getTablesUsed, prepare, queryAsString, quoted, toPreparedStatementString, toString
 
Methods inherited from class jimm.datavision.source.Query
addAllJoins, addJoin, addSort, clearJoins, clearSorts, containsReferenceTo, getEditableWhereClause, getNumSelectables, getWhereClause, indexOfSelectable, joins, reloadColumns, removeJoin, removeSort, selectables, setEditableWhereClause, setWhereClause, sortedSelectables, sortOrderOf, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subreport

protected Subreport subreport

subreportJoins

protected java.util.ArrayList subreportJoins
Constructor Detail

SubreportQuery

public SubreportQuery(Subreport report)
Constructor.

Parameters:
report - the report for which this query will generate SQL
Method Detail

addSubreportJoin

public void addSubreportJoin(Join join)

addSubreportJoins

public void addSubreportJoins(java.util.Collection coll)

parentColumns

public java.util.Iterator parentColumns()
Returns an iterator over all of the columns that need to be included in the parent report's query so that the values are available to this subreport when it builds its query.

Returns:
an iterator over selectables

buildWhereClause

protected void buildWhereClause(java.lang.StringBuffer str,
                                boolean forDisplay)
Overrides:
buildWhereClause in class SQLQuery

getWhereClauseForDisplay

public java.lang.String getWhereClauseForDisplay()
Description copied from class: SQLQuery
Returns the where clause string; may be null. If there are any column names contained in curly braces, we remove the curly braces. Formulas, parameters, and user colums remain as-is.

Implementation note: we can't use StringUtils.replaceDelimited because we modify the symbol that appears before some of the delimited items.

Overrides:
getWhereClauseForDisplay in class SQLQuery
Returns:
the where clause string; may be null
See Also:
Query.getWhereClause()

getWhereClauseForPreparedStatement

public java.lang.String getWhereClauseForPreparedStatement()
Description copied from class: SQLQuery
Returns the where clause string; may be null. If there are any parameter values, we return '?' in their place and save the values for later use.

This code may also modify the clause. For example, a parameter can change the previous comparison operator ("=", "is") based on its arity.

Overrides:
getWhereClauseForPreparedStatement in class SQLQuery
Returns:
the where clause string; may be null
See Also:
Query.getWhereClause()

setParameters

public void setParameters(java.sql.PreparedStatement stmt)
                   throws java.sql.SQLException
Description copied from class: SQLQuery
Given a prepared statement created with the text returned by toPreparedStatementString, plug in all the parameter and formula values.

Overrides:
setParameters in class SQLQuery
Throws:
java.sql.SQLException
See Also:
SQLQuery.toPreparedStatementString()

writeExtras

protected void writeExtras(XMLWriter out)
Description copied from class: Query
This method exists so subclasses can write out extra information.

Overrides:
writeExtras in class Query