Holger's Java API

## com.antelmann.sql
Class PreparedStatementEntryFilter<T>

    java.lang.Object
      com.antelmann.sql.PreparedStatementEntryFilter<T>

All Implemented Interfaces:
  CascadingFilter<T>, Filter<T>, Closeable

    public class PreparedStatementEntryFilter<T>

extends Object
implements CascadingFilter<T>, Closeable

a special filter that directly works off a PreparedStatement; only suitable for pre-filtering from the database, unless an internalFilter is set in addition.

Since:
  20. März 2007, 14:19
Author:
  Holger Antelmann
See Also:
  `BaseRowMapper`

Field Summary
`protected Connection` `con`
`protected Filter<? super T>` `internalFilter`
`protected Object[]` `parameters`
`protected PreparedStatement` `pst`
`protected String` `sql`

Fields inherited from interface com.antelmann.util.Filter
`EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER`

Constructor Summary
`protected` `PreparedStatementEntryFilter()` the fields remain uninitialized; the PreparedStatement must be initialized by the constructor of the subclass
`` `PreparedStatementEntryFilter(Connection con, String sql)`
`` `PreparedStatementEntryFilter(Connection con, String sql, Filter<? super T> internalFilter, Object... parameters)`
`` `PreparedStatementEntryFilter(PreparedStatement pst, Filter<? super T> internalFilter)` when only using this constructor, reInitialize() will throw an IllegalStateException, as the PreparedStatement cannot be regenerated just by itself.

Method Summary
`boolean` `accept(T entry)` if no internalFilter is set, true is returned; otherwise the internalFilter determines the return value
`void` `close()`
`Filter<? super T>` `getInnerFilter()`
`Object[]` `getParameters()`
`PreparedStatement` `getPreparedStatement()`
`String` `getSQLString()`
`void` `reInitialize()` reinitializes the embedded PreparedStatement with the sql string and the parameters; useful to call for reusing the filter after some usage may have closed the statement
`void` `setInnerFilter(Filter<? super T> filter)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### con

    protected Connection con

### pst

    protected PreparedStatement pst

### internalFilter

    protected Filter<? super T> internalFilter

### sql

    protected String sql

### parameters

    protected Object[] parameters

Constructor Detail

### PreparedStatementEntryFilter

    protected PreparedStatementEntryFilter()

  the fields remain uninitialized; the PreparedStatement must be initialized by the constructor of the subclass

### PreparedStatementEntryFilter

    public PreparedStatementEntryFilter(Connection con,
                                        String sql)
                                 throws SQLException

Throws:
  `SQLException`

### PreparedStatementEntryFilter

    public PreparedStatementEntryFilter(Connection con,
                                        String sql,
                                        Filter<? super T> internalFilter,
                                        Object... parameters)
                                 throws SQLException

Throws:
  `SQLException`

### PreparedStatementEntryFilter

    public PreparedStatementEntryFilter(PreparedStatement pst,
                                        Filter<? super T> internalFilter)
                                 throws SQLException

  when only using this constructor, reInitialize() will throw an IllegalStateException, as the PreparedStatement cannot be regenerated just by itself.

  Throws:
    `SQLException`

Method Detail

### reInitialize

    public void reInitialize()
                      throws IllegalStateException,
                             SQLException

  reinitializes the embedded PreparedStatement with the sql string and the parameters; useful to call for reusing the filter after some usage may have closed the statement

  Throws:
    `IllegalStateException`
    `SQLException`

### getPreparedStatement

    public PreparedStatement getPreparedStatement()

### getSQLString

    public String getSQLString()

### getParameters

    public Object[] getParameters()

### 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>`

### accept

    public boolean accept(T entry)

  if no internalFilter is set, true is returned; otherwise the internalFilter determines the return value

  Specified by:
    `accept` in interface `Filter<T>`

### close

    public void close()
               throws IOException

  Specified by:
    `close` in interface `Closeable`
  Throws:
    `IOException`

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