Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java
new file mode 100644
index 0000000000..ec547c74e3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Expr.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.mongodb;
+
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Expr
+{
+ public void evaluate(DBCollection collection, ResultHandler handler)
+ {
+ DBCursor cursor = findDocuments(collection);
+
+ try
+ {
+ while (cursor.hasNext())
+ {
+ DBObject doc = cursor.next();
+ handleDocument(doc, handler);
+ }
+ }
+ finally
+ {
+ cursor.close();
+ }
+ }
+
+ protected void handleDocument(DBObject doc, ResultHandler handler)
+ {
+ }
+
+ protected abstract DBCursor findDocuments(DBCollection collection);
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface ResultHandler
+ {
+
+ }
+}

Back to the top