jclass clazz = (*env)->GetObjectClass(env, obj);
jfieldID dbpID = (*env)->GetFieldID(env, clazz, "dbPointer", "J");
(*env)->SetLongField(env, obj, dbpID, (jlong)db);
+
+ jfieldID pathID = (*env)->GetFieldID(env, clazz, "path", "Ljava/lang/String;");
+ (*env)->SetObjectField(env, obj, pathID, db ? (*env)->NewStringUTF(env, db->metadb->hdb->path) : NULL);
};
static EJDB *get_ejdb_from_object(JNIEnv *env, jobject obj) {
#define JEJDB_H
#include <ejdb_private.h>
-#ifdef _WIN32
-#undef __cplusplus
-#endif
-#include "org_ejdb_driver_EJDBDriver.h"
#include "org_ejdb_driver_EJDB.h"
#include "org_ejdb_driver_EJDBCollection.h"
#include "org_ejdb_driver_EJDBQuery.h"
#define org_ejdb_driver_EJDBCollection_JBTXROLLBACK 4L
#undef org_ejdb_driver_EJDBCollection_JBTXSTATUS
#define org_ejdb_driver_EJDBCollection_JBTXSTATUS 8L
-
/*
* Class: org_ejdb_driver_EJDBCollection
* Method: txControl
+++ /dev/null
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class org_ejdb_driver_EJDBDriver */
-
-#ifndef _Included_org_ejdb_driver_EJDBDriver
-#define _Included_org_ejdb_driver_EJDBDriver
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
package org.ejdb;
+import com.sun.org.apache.xpath.internal.SourceTree;
+
import org.bson.BSONObject;
import org.bson.BasicBSONObject;
import org.ejdb.driver.EJDB;
try {
db.open("test5");
- System.out.println("test EJDB opened");
+ System.out.println("test EJDB opened: " + db.getPath());
EJDBCollection test = db.getCollection("test");
for (BSONObject r : rs) {
System.out.println(r);
}
+ rs.close();
+ System.out.println();
System.out.println(query.findOne());
+ System.out.println();
+
+ query = test.createQuery(new BasicBSONObject("randomBoolean", true));
+ System.out.println("Objects with 'randomBoolean==true': " + query.count());
+ rs = query.find();
+ for (BSONObject r : rs) {
+ System.out.println(r);
+ }
+ rs.close();
+
+ query.getQueryObject().put("smallRandom", new BasicBSONObject("$lt", 6));
+ rs = query.find();
+ System.out.println("Objects with 'randomBoolean==true && smallRandom<6': " + rs.length());
+ for (BSONObject r : rs) {
+ System.out.println(r);
+ }
+ rs.close();
} finally {
db.close();
bsonObject.put("time", System.currentTimeMillis());
bsonObject.put("index", INDEX);
bsonObject.put("random", random.nextLong());
+ bsonObject.put("randomBoolean", random.nextBoolean());
+ bsonObject.put("randomDouble", random.nextDouble());
+ bsonObject.put("smallRandom", random.nextInt(10));
return bsonObject;
}
* @version $Id$
*/
public class EJDB {
- // Open modes
- public static final int JBOREADER = 1 << 0; /**< Open as a reader. */
- public static final int JBOWRITER = 1 << 1; /**< Open as a writer. */
- public static final int JBOCREAT = 1 << 2; /**< Create if db file not exists. */
- public static final int JBOTRUNC = 1 << 3; /**< Truncate db on open. */
- public static final int JBONOLCK = 1 << 4; /**< Open without locking. */
- public static final int JBOLCKNB = 1 << 5; /**< Lock without blocking. */
- public static final int JBOTSYNC = 1 << 6; /**< Synchronize every transaction. */
+ /**
+ * Open as a reader.
+ */
+ public static final int JBOREADER = 1 << 0;
+
+ /**
+ * Open as a writer.
+ */
+ public static final int JBOWRITER = 1 << 1;
+
+ /**
+ * Create if db file not exists.
+ */
+ public static final int JBOCREAT = 1 << 2;
+
+ /**
+ * Truncate db on open.
+ */
+ public static final int JBOTRUNC = 1 << 3;
+
+ /**
+ * Open without locking.
+ */
+ public static final int JBONOLCK = 1 << 4;
+
+ /**
+ * Lock without blocking.
+ */
+ public static final int JBOLCKNB = 1 << 5;
+
+ /**
+ * Synchronize every transaction.
+ */
+ public static final int JBOTSYNC = 1 << 6;
+
+ /**
+ * Default open mode
+ */
public static final int JBO_DEFAULT = (JBOWRITER | JBOCREAT | JBOTSYNC);
static {
private long dbPointer;
- // TODO: move to driver class
+ private String path;
+
+ public String getPath() {
+ return path;
+ }
+
public void open(String path) {
this.open(path, JBO_DEFAULT);
}
+++ /dev/null
-package org.ejdb.driver;
-
-/**
- * @author Tyutyunkov Vyacheslav (tve@softmotions.com)
- * @version $Id$
- */
-public class EJDBDriver {
-}