com.healthmarketscience.jackcess.util
Class RowFilter

java.lang.Object
  extended by com.healthmarketscience.jackcess.util.RowFilter

public abstract class RowFilter
extends Object

The RowFilter class encapsulates a filter test for a table row. This can be used by the apply(Iterable) method to create an Iterable over a table which returns only rows matching some criteria.

Author:
Patricia Donaldson, Xerox Corporation
Usage:
General: This class is general use.

Constructor Summary
RowFilter()
           
 
Method Summary
 Iterable<Row> apply(Iterable<? extends Row> iterable)
          Returns an iterable which filters the given iterable based on this filter.
static Iterable<Row> apply(RowFilter rowFilter, Iterable<? extends Row> iterable)
          Returns an iterable which filters the given iterable based on the given rowFilter.
static RowFilter invert(RowFilter filter)
          Creates a filter which inverts the sense of the given filter (rows which are matched by the given filter will not be matched by the returned filter, and vice versa).
abstract  boolean matches(Row row)
          Returns true if the given table row matches the Filter criteria, false otherwise.
static RowFilter matchPattern(Column columnPattern, Object valuePattern)
          Creates a filter based on a single value row pattern.
static RowFilter matchPattern(Map<String,?> rowPattern)
          Creates a filter based on a row pattern.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowFilter

public RowFilter()
Method Detail

matches

public abstract boolean matches(Row row)
Returns true if the given table row matches the Filter criteria, false otherwise.

Parameters:
row - current row to test for inclusion in the filter

apply

public Iterable<Row> apply(Iterable<? extends Row> iterable)
Returns an iterable which filters the given iterable based on this filter.

Parameters:
iterable - row iterable to filter
Returns:
a filtering iterable

matchPattern

public static RowFilter matchPattern(Map<String,?> rowPattern)
Creates a filter based on a row pattern.

Parameters:
rowPattern - Map from column names to the values to be matched. A table row will match the target if ObjectUtils.equals(rowPattern.get(s), row.get(s)) for all column names in the pattern map.
Returns:
a filter which matches table rows which match the values in the row pattern

matchPattern

public static RowFilter matchPattern(Column columnPattern,
                                     Object valuePattern)
Creates a filter based on a single value row pattern.

Parameters:
columnPattern - column to be matched
valuePattern - value to be matched. A table row will match the target if ObjectUtils.equals(valuePattern, row.get(columnPattern.getName())).
Returns:
a filter which matches table rows which match the value in the row pattern

invert

public static RowFilter invert(RowFilter filter)
Creates a filter which inverts the sense of the given filter (rows which are matched by the given filter will not be matched by the returned filter, and vice versa).

Parameters:
filter - filter which to invert
Returns:
a RowFilter which matches rows not matched by the given filter

apply

public static Iterable<Row> apply(RowFilter rowFilter,
                                  Iterable<? extends Row> iterable)
Returns an iterable which filters the given iterable based on the given rowFilter.

Parameters:
rowFilter - the filter criteria, may be null
iterable - row iterable to filter
Returns:
a filtering iterable (or the given iterable if a null filter was given)


Copyright © 2005–2017 Health Market Science. All rights reserved.