
import traildb.TrailDB;
import traildb.TrailDBConstructor;
import traildb.TrailDBCursor;
import traildb.TrailDBEvent;

import java.util.UUID;
import java.io.FileNotFoundException;

public class Example {

	public static void read() throws FileNotFoundException {
		TrailDB tdb = new TrailDB("tiny.tdb");
		TrailDBCursor cur = tdb.cursorNew();
		long numCookies = tdb.numTrails();
		UUID uuid;
		TrailDBEvent event;
		for (int i=0; i < numCookies; i++) {
			// uuid = tdb.getUUID(i);
			// System.out.println(uuid);
			cur.getTrail(i);
			while ((event = cur.next()) != null) {
				System.out.println(event.timestamp + " " + event.getItem(0));
			}
		}
	}

	public static void main(String[] args) {
		TrailDBConstructor cons = new TrailDBConstructor("tiny", new String[] {"user", "action"});

		UUID cookie1 = UUID.randomUUID();
		UUID cookie2 = UUID.randomUUID();

		System.out.println(cookie1 + " " + cookie2);

		cons.add(cookie1, 1, new String[] {"bob", "run"});
		cons.add(cookie2, 2, new String[] {"fred", "walk"});
		cons.add(cookie1, 4, new String[] {"jerry", "speak"});
		cons.add(cookie1, 5, new String[] {"ted", "fly"});

		cons.finalize();
		cons.close();

		System.out.println("Finished writing");
		read();
	}
}
@@ -257,16 +257,52 @@
 ption %7B%0A
+%09%09System.out.println(%22Begin Test%22);%0A
 %09%09TrailD
@@ -379,179 +379,85 @@
 ;%0A%09%09
-long numCookies = tdb.numTrails();%0A%09%09UUID uuid;%0A%09%09TrailDBEvent event;%0A%09%09for (int i=0; i %3C numCookies; i++) %7B%0A%09%09%09// uuid = tdb.getUUID(i
+TrailDBEvent e1;%0A%09%09TrailDBEvent e2;%0A%0A%09%09cur.getTrail(0
 );%0A
+%0A
 %09%09
-%09// System.out.println(uuid);%0A%09
+e1 = cur.next();%0A%0A
 %09%09cu
@@ -471,128 +471,65 @@
 ail(
-i
+1
 );%0A
+%0A
 %09%09
-%09while ((event = cur.next()) != null) %7B%0A%09%09%09%09System.out.println(event.timestamp + %22 %22 + event.getItem(0));%0A%09%09%09%7D%0A%09%09%7D
+e2 = cur.next();%0A%09%09System.out.println(%22End Test%22);
 %0A%09%7D%0A
@@ -568,16 +568,45 @@
 %5B%5D args)
+ throws FileNotFoundException
  %7B%0A%09%09Tra
@@ -771,56 +771,8 @@
 );%0A%0A
-%09%09System.out.println(cookie1 + %22 %22 + cookie2);%0A%0A
 %09%09co

Fix example