package io.sqooba.traildb;

import java.nio.ByteBuffer;
import java.util.Iterator;

/**
 * Class representing a cursor over a particular trail of the database. The cursor is initially constructed from the
 * TrailDB.trail() method. The cursor points to the current event and this event is updated each time a .next() is
 * called.
 * 
 * @author B. Sottas
 *
 */
public class TrailDBIterator implements Iterable<TrailDBEvent>, AutoCloseable {

    private ByteBuffer cursor;
    private TrailDBEvent event;

    protected TrailDBIterator(ByteBuffer cursor, TrailDBEvent event) {
        this.event = event;
        this.cursor = cursor;
    }

    @Override
    public void close() {
        if (this.cursor != null) {
            TrailDBNative.INSTANCE.cursorFree(this.cursor);
            this.cursor = null;
        }
    }

    @Override
    public Iterator<TrailDBEvent> iterator() {
        return new Iterator<TrailDBEvent>() {

            @Override
            public TrailDBEvent next() {
                if (!TrailDBIterator.this.event.isBuilt()) {
                    TrailDBNative.INSTANCE.cursorNext(TrailDBIterator.this.cursor, TrailDBIterator.this.event);
                }
                return new TrailDBEvent(TrailDBIterator.this.event);
            }

            @Override
            public boolean hasNext() {
                return TrailDBNative.INSTANCE.cursorNext(TrailDBIterator.this.cursor, TrailDBIterator.this.event) == 0;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}

@@ -1210,25 +1210,8 @@
 urn 
-new TrailDBEvent(
 Trai
@@ -1224,33 +1224,32 @@
 rator.this.event
-)
 ;%0A            %7D%0A
@@ -1591,11 +1591,123 @@
 %7D;%0A    %7D
+%0A%0A    public TrailDBEvent getCurrentEvent() %7B%0A        return new TrailDBEvent(TrailDBIterator.this.event);%0A    %7D
 %0A%7D%0A

Fix conflict.