summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/cursor
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-03-28 22:00:24 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-03-28 22:00:24 +0000
commit8809341248c62b15b78d7e6d8e06ab2ec3793c8e (patch)
treef39d7353987e025758e0a3abe1ffb49a48e9be9e /src/main/java/com/amazon/carbonado/cursor
parent65478f17ada9df04c4c2afa734378bb50ec2bd13 (diff)
Merged 1.2-dev to trunk.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/cursor')
-rw-r--r--src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java b/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java
index c25f8db..faf990d 100644
--- a/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java
+++ b/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java
@@ -38,6 +38,27 @@ import com.amazon.carbonado.filter.OpenFilter;
*/
public abstract class FilteredCursor<S> extends AbstractCursor<S> {
/**
+ * Returns a Cursor that is filtered by the given filter expression and values.
+ *
+ * @param cursor cursor to wrap
+ * @param type type of storable
+ * @param filter filter to apply
+ * @param filterValues values for filter
+ * @return wrapped cursor which filters results
+ * @throws IllegalStateException if any values are not specified
+ * @throws IllegalArgumentException if any argument is null
+ */
+ public static <S extends Storable> Cursor<S> applyFilter(Cursor<S> cursor,
+ Class<S> type,
+ String filter,
+ Object... filterValues)
+ {
+ Filter<S> f = Filter.filterFor(type, filter).bind();
+ FilterValues<S> fv = f.initialFilterValues().withValues(filterValues);
+ return applyFilter(f, fv, cursor);
+ }
+
+ /**
* Returns a Cursor that is filtered by the given Filter and FilterValues.
* The given Filter must be composed only of the same PropertyFilter
* instances as used to construct the FilterValues. An
@@ -61,6 +82,9 @@ public abstract class FilteredCursor<S> extends AbstractCursor<S> {
throw new IllegalArgumentException();
}
+ // Make sure the filter is the same one that filterValues should be using.
+ filter = filter.bind();
+
return FilteredCursorGenerator.getFactory(filter)
.newFilteredCursor(cursor, filterValues.getValuesFor(filter));
}