Holger's
Java API

com.antelmann.util
Class OffsetFilter<T>

java.lang.Object
  extended by com.antelmann.util.OffsetFilter<T>
All Implemented Interfaces:
CascadingFilter<T>, Filter<T>, Wrapped<Filter<? super T>>

public class OffsetFilter<T>
extends Object
implements CascadingFilter<T>, Wrapped<Filter<? super T>>

a filter that specifies to a supporting implementation that not all results are desired, but only those starting at a given offset and limited to a given limit. By itself, it maintains a counter that controls the accept method. This filter is supported by JDBCRowStore to limit the returned result; only the inner filter is given to the mapper.

Since:
29.08.2009, 12:09:59
Author:
Holger Antelmann
See Also:
JDBCRowStore.fetch(Filter), JDBCRowStore.fetchStubs(Filter)

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
OffsetFilter(int limit)
           
OffsetFilter(int limit, Filter<? super T> innerFilter)
           
OffsetFilter(int offset, int limit, Filter<? super T> innerFilter)
           
 
Method Summary
 boolean accept(T entry)
          returns true only if the given entry is accepted by this filter
 OffsetFilter<T> createNextFilter()
          returns a new filter that moves the offset by the limit
 Filter<? super T> getInnerFilter()
           
 int getLimit()
           
 int getOffset()
           
 void resetCounter()
           
 void setInnerFilter(Filter<? super T> filter)
           
 Filter<? super T> unwrap()
          returns the embedded instance that this wrapper encloses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OffsetFilter

public OffsetFilter(int limit)

OffsetFilter

public OffsetFilter(int limit,
                    Filter<? super T> innerFilter)

OffsetFilter

public OffsetFilter(int offset,
                    int limit,
                    Filter<? super T> innerFilter)
Parameters:
offset - allows to start not at the first row, but at the given offset (0 means to start at the beginning)
limit - specifies the maximum number of rows to be considered
innerFilter - the actual filter that will be used by the mapper
Method Detail

createNextFilter

public OffsetFilter<T> createNextFilter()
returns a new filter that moves the offset by the limit


getOffset

public int getOffset()

getLimit

public int getLimit()

resetCounter

public void resetCounter()

accept

public boolean accept(T entry)
Description copied from interface: Filter
returns true only if the given entry is accepted by this filter

Specified by:
accept in interface Filter<T>

unwrap

public Filter<? super T> unwrap()
Description copied from interface: Wrapped
returns the embedded instance that this wrapper encloses

Specified by:
unwrap in interface Wrapped<Filter<? super 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>


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