org.dbforms.config
Class Query

java.lang.Object
  extended by org.dbforms.config.Table
      extended by org.dbforms.config.Query
All Implemented Interfaces:
Serializable

public class Query
extends Table

This class represents the query tag in dbforms-config.xml (dbforms config xml file)

it's derived from the table class and overloads the necessary methods.

Author:
Henner Kollmann
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.dbforms.config.Table
BLOB_CLASSIC, BLOB_INTERCEPTOR, CALC_FIELD, DB_FIELD, SEARCH_FIELD
 
Constructor Summary
Query()
           
 
Method Summary
 void addSearchField(Field field)
          adds a Field-Object to this table and puts it into othere datastructure for further references (this method gets called from DbFormsConfig)
 Field getField(int fieldId)
          returns the Field-Objet with specified id overloaded from Table Specials: 1. if fieldId is in range from search fields, get from search fields 2.
 Field getFieldByName(String name)
          returns the field-objects as specified by name (or null if no field with the specified name exists in this table) overloaded from Table Specials: 1.
 Vector getFields()
          returns the vector of fields this table constists of overloaded from Table Specials: if view has field defined, use this otherwise use fields from parent table
 String getHaving()
          DOCUMENT ME!
 Vector getKey()
          returns the key of this table (consisting of Field-Objects representing key-fields) overloaded from Table Specials: if key of view is not defined (if view has not defined fields) use keys from parent table
 Hashtable getNamesHashtable(String core)
          DOCUMENT ME!
 String getQueryFrom()
          returns the from part of a query. overloaded from Table if from is defind in dbforms-config.xml use this, else method from Table
protected  String getQueryOrderBy(FieldValue[] fvOrder)
          returns the part of the orderby-clause represented by this FieldValue object.
 String getQuerySelect(Vector fieldsToSelect)
          returns the select part of a query overloaded from Table extends fieldnames with getting expression
 Vector getSearchFields()
          Returns the search fields search fields are fields in the query which are only used in the where part, not in the select part
 String getSelectQuery(Vector fieldsToSelect, FieldValue[] fvEqual, FieldValue[] fvOrder, String sqlFilter, int compareMode)
          Prepares the Querystring for the select statement Order of parts: 1.
 boolean hasDistinctSet()
          DOCUMENT ME!
 boolean needOrderWithPos()
          return OrderWithPos OrderWithPos will be set if - groupBy is set - OrderWithPos is defined in dbforms-config.xml
 int populateWhereEqualsClause(FieldValue[] fvEqual, PreparedStatement ps, int curCol)
          situation: we have built a query (involving the getWhereEqualsClause() method) and now we want to prepare the statemtent - provide actual values for the the '?'
 void setDistinct(String value)
          DOCUMENT ME!
 void setFollowAfterWhere(String followAfterWhere)
          Sets the followAfterWhere.
 void setFrom(String value)
          set from, if defined in dbforms-config-xml (this method gets called from XML-digester)
 void setGroupBy(String value)
          set groupBy, if defined in dbforms-config-xml (this method gets called from XML-digester)
 void setHaving(String value)
          DOCUMENT ME!
 void setOrderWithPos(String value)
          set OrderWithPos, if defined in dbforms-config-xml (this method gets called from XML-digester) if set the ORDER BY statment will use position number instead of field names in ORDER BY
 void setWhere(String value)
          set whereClause, if defined in dbforms-config-xml (this method gets called from XML-digester)
 
Methods inherited from class org.dbforms.config.Table
addCalcField, addField, addForeignKey, addInterceptor, checkFieldId, containsDiskblob, createOrderFieldValues, decodeFieldId, doConstrainedSelect, doFreeFormSelect, encodeFieldId, fillWithValues, getAlias, getBlobHandling, getBlobHandlingStrategy, getCalcFields, getConfig, getDataAccessClass, getDefaultOrder, getDefaultVisibleFields, getDefaultVisibleFieldsFormat, getDeleteStatement, getDisblobSelectStatement, getDiskblobs, getDoSelectResultSet, getEscaper, getEscaperClass, getFieldName, getFieldValues, getFilterFieldArray, getForeignKeys, getFreeFormSelectQuery, getGrantedPrivileges, getId, getInsertStatement, getInterceptors, getKeyPositionString, getKeyPositionString, getKeyPositionString, getName, getOrderBy, getPositionString, getPositionString, getPositionString, getPositionString, getQueryToChange, getQueryWhere, getSelectStatement, getTableEvents, getUpdateStatement, getWhereClause, getWhereClauseForKeyFields, hasInterceptors, hasUserPrivileg, initDefaultOrder, isCalcField, mapChildFieldValues, populateWhereClauseWithKeyFields, processInterceptors, setAlias, setBlobHandling, setDataAccessClass, setDefaultVisibleFields, setDefaultVisibleFieldsFormat, setEscaperClass, setGrantedPrivileges, setId, setName, setOrderBy, setTableEvents, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Query

public Query()
Method Detail

setDistinct

public void setDistinct(String value)
DOCUMENT ME!

Parameters:
value - the value to set

getField

public Field getField(int fieldId)
returns the Field-Objet with specified id overloaded from Table Specials: 1. if fieldId is in range from search fields, get from search fields 2. if has fields try to find in fields 3. if not has fields try to find in parent table

Overrides:
getField in class Table
Parameters:
fieldId - The id of the field to be returned
Returns:
the field

getFieldByName

public Field getFieldByName(String name)
returns the field-objects as specified by name (or null if no field with the specified name exists in this table) overloaded from Table Specials: 1. Try to find in fields 2. Try to find in search fields 3. Try to find in parent table

Overrides:
getFieldByName in class Table
Parameters:
name - The name of the field
Returns:
the field

getFields

public Vector getFields()
returns the vector of fields this table constists of overloaded from Table Specials: if view has field defined, use this otherwise use fields from parent table

Overrides:
getFields in class Table
Returns:
the fields

setFollowAfterWhere

public void setFollowAfterWhere(String followAfterWhere)
Sets the followAfterWhere.

Parameters:
followAfterWhere - The followAfterWhere to set

setFrom

public void setFrom(String value)
set from, if defined in dbforms-config-xml (this method gets called from XML-digester)

Parameters:
value - sql from

setGroupBy

public void setGroupBy(String value)
set groupBy, if defined in dbforms-config-xml (this method gets called from XML-digester)

Parameters:
value - sql group by

setHaving

public void setHaving(String value)
DOCUMENT ME!

Parameters:
value - the value to set

getHaving

public String getHaving()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getKey

public Vector getKey()
returns the key of this table (consisting of Field-Objects representing key-fields) overloaded from Table Specials: if key of view is not defined (if view has not defined fields) use keys from parent table

Overrides:
getKey in class Table
Returns:
the keys

getNamesHashtable

public Hashtable getNamesHashtable(String core)
DOCUMENT ME!

Overrides:
getNamesHashtable in class Table
Parameters:
core - starting tag for the fields
Returns:
the hash table. Hashtables are build from fields + searchfields!

setOrderWithPos

public void setOrderWithPos(String value)
set OrderWithPos, if defined in dbforms-config-xml (this method gets called from XML-digester) if set the ORDER BY statment will use position number instead of field names in ORDER BY

Parameters:
value - sets orderWithPos

getQueryFrom

public String getQueryFrom()
returns the from part of a query. overloaded from Table if from is defind in dbforms-config.xml use this, else method from Table

Overrides:
getQueryFrom in class Table
Returns:
sql from

getQuerySelect

public String getQuerySelect(Vector fieldsToSelect)
returns the select part of a query overloaded from Table extends fieldnames with getting expression

Overrides:
getQuerySelect in class Table
Parameters:
fieldsToSelect - fieldlist
Returns:
sql select part

getSearchFields

public Vector getSearchFields()
Returns the search fields search fields are fields in the query which are only used in the where part, not in the select part

Returns:
search field list

getSelectQuery

public String getSelectQuery(Vector fieldsToSelect,
                             FieldValue[] fvEqual,
                             FieldValue[] fvOrder,
                             String sqlFilter,
                             int compareMode)
Prepares the Querystring for the select statement Order of parts: 1. where condition from config (no params!) 2. sqlFilter (fild in getDoSelectResultSet!) 3. where condition generated from search fields (fild in overloaded populateWhereEqualsClause) 4. where condition generated from having / ordering fields (fild in overloaded populateWhereEqualsClause) Retrieving the parameters in getDoSelectResultSet() must match this order!

Overrides:
getSelectQuery in class Table
Parameters:
fieldsToSelect - vector of fields to be selected
fvEqual - fieldValues representing values we are looking for
fvOrder - fieldValues representing needs for order clauses
sqlFilter - sql condition to and with the where clause
compareMode - compare mode value for generating the order clause
Returns:
the query string

setWhere

public void setWhere(String value)
set whereClause, if defined in dbforms-config-xml (this method gets called from XML-digester)

Parameters:
value - sql where

addSearchField

public void addSearchField(Field field)
                    throws Exception
adds a Field-Object to this table and puts it into othere datastructure for further references (this method gets called from DbFormsConfig)

Parameters:
field - field to add
Throws:
Exception - DOCUMENT ME!

hasDistinctSet

public boolean hasDistinctSet()
DOCUMENT ME!

Returns:
DOCUMENT ME!

needOrderWithPos

public boolean needOrderWithPos()
return OrderWithPos OrderWithPos will be set if - groupBy is set - OrderWithPos is defined in dbforms-config.xml

Returns:
orderWithPos

populateWhereEqualsClause

public int populateWhereEqualsClause(FieldValue[] fvEqual,
                                     PreparedStatement ps,
                                     int curCol)
                              throws SQLException
situation: we have built a query (involving the getWhereEqualsClause() method) and now we want to prepare the statemtent - provide actual values for the the '?' placeholders

Overrides:
populateWhereEqualsClause in class Table
Parameters:
fvEqual - the array of FieldValue objects
ps - the PreparedStatement object
curCol - the current PreparedStatement column; points to a PreparedStatement xxx value
Returns:
the current column value
Throws:
SQLException - if any error occurs

getQueryOrderBy

protected String getQueryOrderBy(FieldValue[] fvOrder)
returns the part of the orderby-clause represented by this FieldValue object. FieldName [DESC] (ASC will be not printed because it is defined DEFAULT in SQL if there are RDBMS which do not tolerate this please let me know; then i'll change it) overloaded from Table if from is defind in dbforms-config.xml use this, else method from Table

Overrides:
getQueryOrderBy in class Table
Parameters:
fvOrder - order list
Returns:
sql order by


Copyright © 2002-2006 DbForms. All Rights Reserved.