Class RowFilter
- java.lang.Object
-
- com.healthmarketscience.jackcess.util.RowFilter
-
public abstract class RowFilter extends Object implements Predicate<Row>
The RowFilter class encapsulates a filter test for a table row. This can be used by theapply(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
Constructors Constructor Description RowFilter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Iterable<Row>apply(RowFilter rowFilter, Iterable<? extends Row> iterable)Returns an iterable which filters the given iterable based on the given rowFilter.Iterable<Row>apply(Iterable<? extends Row> iterable)Returns an iterable which filters the given iterable based on this filter.Stream<Row>filter(Iterable<? extends Row> iterable)Convenience method to apply this filter to the given iterable and return it as a Stream.static RowFilterinvert(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 booleanmatches(Row row)Returnstrueif the given table row matches the Filter criteria,falseotherwise.static RowFiltermatchPattern(Column columnPattern, Object valuePattern)Creates a filter based on a single value row pattern.static RowFiltermatchPattern(Map<String,?> rowPattern)Creates a filter based on a row pattern.booleantest(Row row)Adaptation of this class forPredicatesupport.
-
-
-
Method Detail
-
matches
public abstract boolean matches(Row row)
Returnstrueif the given table row matches the Filter criteria,falseotherwise.- Parameters:
row- current row to test for inclusion in the filter
-
test
public boolean test(Row row)
Adaptation of this class forPredicatesupport. Uses thematches(com.healthmarketscience.jackcess.Row)method.
-
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
-
filter
public Stream<Row> filter(Iterable<? extends Row> iterable)
Convenience method to apply this filter to the given iterable and return it as a Stream.
-
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 ifObjects.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 matchedvaluePattern- value to be matched. A table row will match the target ifObjects.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 benulliterable- row iterable to filter- Returns:
- a filtering iterable (or the given iterable if a
nullfilter was given)
-
-