Holger's
Java API

com.antelmann.sql
Class SQLComboFilter<T>

java.lang.Object
  extended by com.antelmann.sql.SQLComboFilter<T>
All Implemented Interfaces:
SQLComboFilterSupported<T>, CascadingFilter<T>, Filter<T>, Serializable

public class SQLComboFilter<T>
extends Object
implements Serializable, SQLComboFilterSupported<T>, CascadingFilter<T>

allows to flexibly combine multiple different filter that all can be effectively applied to a BaseRowMapper. Note that the order of embedded SQLMapFilters or SQLComboFilter is completely ignored! Instead, set the order for this top-level SQLComboFilter to have it recognized by the BaseRowMapper Most flexibility is obtained by using one SQLComboFilter in another.

Since:
22.01.2009, 16:44:45
Author:
Holger Antelmann
See Also:
SQLMapFilter, FullTextSearchFilter, Serialized Form

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
SQLComboFilter(SQLComboFilterSupported<? super T> filter)
           
 
Method Summary
 boolean accept(T entry)
          this implementation returns false if and only if an existing innerFilter doesn't accept the given entry
 void add(SQLComboFilterSupported<? super T> filter, boolean combineWithAndIfTrue)
           
protected  void addFilterStatement(Connection con, String table, Filter<?> filter, StringBuilder sb, ArrayList<Object> params)
           
protected  void addWhereClause(Connection con, String table, StringBuilder sb, ArrayList<Object> params)
           
 SQLComboFilter<Stub<?>> asStubFilter()
           
 boolean contains(Filter<?> filter)
           
 PreparedStatementEntryFilter<T> createPreparedStatementEntryFilter(BaseRowMapper<?> mapper, Connection con, String tableQuery, String... selectColumns)
           
 PreparedStatementEntryFilter<T> createPreparedStatementEntryFilter(Connection con, String tableQuery, String... selectColumns)
           
<E extends DBEntry>
PreparedStatementEntryFilter<T>
createPreparedStatementEntryFilter(DBClassStore<E> store)
          Deprecated. cannot extract the mapper this way, so this is discouraged
 String createQueryString(BaseRowMapper<?> mapper, Connection con, String tableQuery, ArrayList<Object> params, String... selectColumns)
           
 SubSelectCondition createSubSelectCondition(BaseRowMapper<?> mapper, Connection con, String tableQuery, String idColumn)
           
 SubSelectCondition createSubSelectCondition(Connection con, String tableQuery, String idColumn)
           
 SubSelectCondition createSubSelectCondition(DBClassStore<?> store)
           
 Filter<?>[] getAllFilters()
          returns all filters that this instance is using in some combined fashion
 Filter<? super T> getInnerFilter()
           
 String[] getRestrictToColumns()
          see setRestrictToColumns(String...)
 boolean hasConditions()
           
protected static boolean hasConditions(Filter<?> filter)
           
 boolean isNegated()
          if true, the generated PreparedStatement will use 'not' to negate the entire statement; false is the default.
 void setInnerFilter(Filter<? super T> filter)
           
 void setNegated(boolean flag)
          allows to negate the entire where-clause of the PreparedStatement when it is generated; the inner filter remains untouched.
 void setOrderByColumns(String... orderByColumns)
           
 void setRestrictToColumns(String... columns)
          allows to override the restricted columns to be mapped; the override only applies if a non-null, non-empty array is given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLComboFilter

public SQLComboFilter(SQLComboFilterSupported<? super T> filter)
Method Detail

isNegated

public boolean isNegated()
if true, the generated PreparedStatement will use 'not' to negate the entire statement; false is the default.

See Also:
setNegated(boolean)

setNegated

public void setNegated(boolean flag)
allows to negate the entire where-clause of the PreparedStatement when it is generated; the inner filter remains untouched.

See Also:
createPreparedStatementEntryFilter(Connection, String, String...)

getAllFilters

public Filter<?>[] getAllFilters()
returns all filters that this instance is using in some combined fashion


createPreparedStatementEntryFilter

@Deprecated
public <E extends DBEntry> PreparedStatementEntryFilter<T> createPreparedStatementEntryFilter(DBClassStore<E> store)
                                                                   throws SQLException
Deprecated. cannot extract the mapper this way, so this is discouraged

Throws:
SQLException

createPreparedStatementEntryFilter

public PreparedStatementEntryFilter<T> createPreparedStatementEntryFilter(Connection con,
                                                                          String tableQuery,
                                                                          String... selectColumns)
                                                                   throws SQLException
Throws:
SQLException

createPreparedStatementEntryFilter

public PreparedStatementEntryFilter<T> createPreparedStatementEntryFilter(BaseRowMapper<?> mapper,
                                                                          Connection con,
                                                                          String tableQuery,
                                                                          String... selectColumns)
                                                                   throws SQLException
Throws:
SQLException

createSubSelectCondition

public SubSelectCondition createSubSelectCondition(DBClassStore<?> store)
                                            throws SQLException
Throws:
SQLException

createSubSelectCondition

public SubSelectCondition createSubSelectCondition(Connection con,
                                                   String tableQuery,
                                                   String idColumn)
                                            throws SQLException
Throws:
SQLException

createSubSelectCondition

public SubSelectCondition createSubSelectCondition(BaseRowMapper<?> mapper,
                                                   Connection con,
                                                   String tableQuery,
                                                   String idColumn)
                                            throws SQLException
Throws:
SQLException

createQueryString

public String createQueryString(BaseRowMapper<?> mapper,
                                Connection con,
                                String tableQuery,
                                ArrayList<Object> params,
                                String... selectColumns)
                         throws SQLException
Throws:
SQLException

hasConditions

public boolean hasConditions()

hasConditions

protected static boolean hasConditions(Filter<?> filter)

addWhereClause

protected void addWhereClause(Connection con,
                              String table,
                              StringBuilder sb,
                              ArrayList<Object> params)
                       throws SQLException
Throws:
SQLException

addFilterStatement

protected void addFilterStatement(Connection con,
                                  String table,
                                  Filter<?> filter,
                                  StringBuilder sb,
                                  ArrayList<Object> params)
                           throws SQLException
Throws:
SQLException

setOrderByColumns

public void setOrderByColumns(String... orderByColumns)

add

public void add(SQLComboFilterSupported<? super T> filter,
                boolean combineWithAndIfTrue)

contains

public boolean contains(Filter<?> filter)

accept

public boolean accept(T entry)
this implementation returns false if and only if an existing innerFilter doesn't accept the given entry

Specified by:
accept in interface Filter<T>

getInnerFilter

public Filter<? super T> getInnerFilter()
Specified by:
getInnerFilter in interface CascadingFilter<T>

setInnerFilter

public void setInnerFilter(Filter<? super T> filter)
Specified by:
setInnerFilter in interface CascadingFilter<T>

setRestrictToColumns

public void setRestrictToColumns(String... columns)
allows to override the restricted columns to be mapped; the override only applies if a non-null, non-empty array is given. Note that you must not forget to include the id column name; otherwise a query would fail.

See Also:
BaseRowMapper.setRestrictedMappedColumns(String[])

getRestrictToColumns

public String[] getRestrictToColumns()
see setRestrictToColumns(String...)


asStubFilter

public SQLComboFilter<Stub<?>> asStubFilter()
                                     throws RuntimeException
Throws:
RuntimeException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads