com.hazelcast.query
Class PagingPredicate

java.lang.Object
  extended by com.hazelcast.query.PagingPredicate
All Implemented Interfaces:
DataSerializable, IndexAwarePredicate, Predicate, Serializable

public class PagingPredicate
extends Object
implements IndexAwarePredicate, DataSerializable

This class is a special Predicate which helps to get a page-by-page result of a query Can be constructed with a page-size, an inner predicate for filtering, A comparator for sorting \ This class is not thread-safe and stateless. To be able to reuse for another query, one should call reset()

See Also:
Serialized Form

Constructor Summary
PagingPredicate()
          Used for serialization internally
PagingPredicate(Comparator<Map.Entry> comparator, int pageSize)
          Construct with a comparator and pageSize results will not be filtered results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0
PagingPredicate(int pageSize)
          Construct with a pageSize results will not be filtered results will be natural ordered throws IllegalArgumentException if pageSize is not greater than 0
PagingPredicate(Predicate predicate, Comparator<Map.Entry> comparator, int pageSize)
          Construct with an inner predicate, comparator and pageSize results will be filtered via inner predicate results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate
PagingPredicate(Predicate predicate, int pageSize)
          Construct with an inner predicate and pageSize results will be filtered via inner predicate results will be natural ordered throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate
 
Method Summary
 boolean apply(Map.Entry mapEntry)
          Used for delegating filtering to inner predicate
 Set<com.hazelcast.query.impl.QueryableEntry> filter(com.hazelcast.query.impl.QueryContext queryContext)
          Used if inner predicate is instanceof IndexAwarePredicate for filtering
 Map.Entry getAnchor()
           
 Comparator<Map.Entry> getComparator()
           
 com.hazelcast.util.IterationType getIterationType()
           
 int getPage()
           
 int getPageSize()
           
 Predicate getPredicate()
           
 boolean isIndexed(com.hazelcast.query.impl.QueryContext queryContext)
          Used if inner predicate is instanceof IndexAwarePredicate for checking if indexed
 void nextPage()
          setting the page value to next page
 void previousPage()
          setting the page value to previous page
 void readData(com.hazelcast.nio.ObjectDataInput in)
           
 void reset()
          resets for reuse
 void setIterationType(com.hazelcast.util.IterationType iterationType)
           
 void writeData(com.hazelcast.nio.ObjectDataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagingPredicate

public PagingPredicate()
Used for serialization internally


PagingPredicate

public PagingPredicate(int pageSize)
Construct with a pageSize results will not be filtered results will be natural ordered throws IllegalArgumentException if pageSize is not greater than 0

Parameters:
pageSize -

PagingPredicate

public PagingPredicate(Predicate predicate,
                       int pageSize)
Construct with an inner predicate and pageSize results will be filtered via inner predicate results will be natural ordered throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate

Parameters:
predicate -
pageSize -

PagingPredicate

public PagingPredicate(Comparator<Map.Entry> comparator,
                       int pageSize)
Construct with a comparator and pageSize results will not be filtered results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0

Parameters:
comparator -
pageSize -

PagingPredicate

public PagingPredicate(Predicate predicate,
                       Comparator<Map.Entry> comparator,
                       int pageSize)
Construct with an inner predicate, comparator and pageSize results will be filtered via inner predicate results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate

Parameters:
predicate -
comparator -
pageSize -
Method Detail

filter

public Set<com.hazelcast.query.impl.QueryableEntry> filter(com.hazelcast.query.impl.QueryContext queryContext)
Used if inner predicate is instanceof IndexAwarePredicate for filtering

Specified by:
filter in interface IndexAwarePredicate
Parameters:
queryContext -
Returns:

isIndexed

public boolean isIndexed(com.hazelcast.query.impl.QueryContext queryContext)
Used if inner predicate is instanceof IndexAwarePredicate for checking if indexed

Specified by:
isIndexed in interface IndexAwarePredicate
Parameters:
queryContext -
Returns:

apply

public boolean apply(Map.Entry mapEntry)
Used for delegating filtering to inner predicate

Specified by:
apply in interface Predicate
Parameters:
mapEntry -
Returns:

reset

public void reset()
resets for reuse


nextPage

public void nextPage()
setting the page value to next page


previousPage

public void previousPage()
setting the page value to previous page


getIterationType

public com.hazelcast.util.IterationType getIterationType()

setIterationType

public void setIterationType(com.hazelcast.util.IterationType iterationType)

getPage

public int getPage()

getPageSize

public int getPageSize()

getPredicate

public Predicate getPredicate()

getComparator

public Comparator<Map.Entry> getComparator()

getAnchor

public Map.Entry getAnchor()

writeData

public void writeData(com.hazelcast.nio.ObjectDataOutput out)
               throws IOException
Specified by:
writeData in interface DataSerializable
Throws:
IOException

readData

public void readData(com.hazelcast.nio.ObjectDataInput in)
              throws IOException
Specified by:
readData in interface DataSerializable
Throws:
IOException


Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.