mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java [186:395]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public void before( Tuple<K, V> element ) throws LdapException, CursorException
    {
        beforeKey( element.getKey() );
    }


    /**
     * {@inheritDoc}
     */
    public void after( Tuple<K, V> element ) throws LdapException, CursorException
    {
        afterKey( element.getKey() );
    }


    /**
     * {@inheritDoc}
     */
    public void beforeFirst() throws LdapException, CursorException
    {
        checkNotClosed();

        try
        {
            if ( browser == null )
            {
                browser = table.getBTree().browse();
            }

            browser.beforeFirst();
            clearValue();
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
        catch ( KeyNotFoundException knfe )
        {
            throw new CursorException( knfe );
        }
    }


    /**
     * {@inheritDoc}
     */
    public void afterLast() throws LdapException, CursorException
    {
        checkNotClosed();

        try
        {
            if ( browser == null )
            {
                browser = table.getBTree().browse();
            }

            browser.afterLast();
            clearValue();
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
        catch ( KeyNotFoundException knfe )
        {
            throw new CursorException( knfe );
        }
    }


    /**
     * {@inheritDoc}
     */
    public boolean first() throws LdapException, CursorException
    {
        beforeFirst();

        return next();
    }


    /**
     * {@inheritDoc}
     */
    public boolean last() throws LdapException, CursorException
    {
        afterLast();
        return previous();
    }


    /**
     * {@inheritDoc}
     */
    public boolean previous() throws LdapException, CursorException
    {
        checkNotClosed();
        if ( browser == null )
        {
            afterLast();
        }

        try
        {
            if ( browser.hasPrev() )
            {
                org.apache.directory.mavibot.btree.Tuple<K, V> tuple = browser.prev();

                returnedTuple.setKey( tuple.getKey() );
                returnedTuple.setValue( tuple.getValue() );
                valueAvailable = true;
                return true;
            }
            else
            {
                clearValue();
                return false;
            }
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
    }


    /**
     * {@inheritDoc}
     */
    public boolean next() throws LdapException, CursorException
    {
        checkNotClosed();

        if ( browser == null )
        {
            beforeFirst();
        }

        try
        {
            if ( browser.hasNext() )
            {
                org.apache.directory.mavibot.btree.Tuple<K, V> tuple = browser.next();

                returnedTuple.setKey( tuple.getKey() );
                returnedTuple.setValue( tuple.getValue() );
                valueAvailable = true;
                return true;
            }
            else
            {
                clearValue();
                return false;
            }
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
    }


    /**
     * {@inheritDoc}
     */
    public Tuple<K, V> get() throws CursorException
    {
        checkNotClosed();
        if ( valueAvailable )
        {
            return returnedTuple;
        }

        throw new InvalidCursorPositionException();
    }


    /**
     * {@inheritDoc}
     */
    @Override
    public void close() throws IOException
    {
        LOG_CURSOR.debug( "Closing MavibotCursor {}", this );
        super.close();
        closeBrowser( browser );
    }


    /**
     * {@inheritDoc}
     */
    @Override
    public void close( Exception cause ) throws IOException
    {
        LOG_CURSOR.debug( "Closing MavibotCursor {}", this );
        super.close( cause );
        closeBrowser( browser );
    }


    /**
     * Close the browser
     */
    private void closeBrowser( TupleCursor<K, V> browser )
    {
        if ( browser != null )
        {
            browser.close();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



mavibotv2-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java [186:395]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public void before( Tuple<K, V> element ) throws LdapException, CursorException
    {
        beforeKey( element.getKey() );
    }


    /**
     * {@inheritDoc}
     */
    public void after( Tuple<K, V> element ) throws LdapException, CursorException
    {
        afterKey( element.getKey() );
    }


    /**
     * {@inheritDoc}
     */
    public void beforeFirst() throws LdapException, CursorException
    {
        checkNotClosed();

        try
        {
            if ( browser == null )
            {
                browser = table.getBTree().browse();
            }

            browser.beforeFirst();
            clearValue();
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
        catch ( KeyNotFoundException knfe )
        {
            throw new CursorException( knfe );
        }
    }


    /**
     * {@inheritDoc}
     */
    public void afterLast() throws LdapException, CursorException
    {
        checkNotClosed();

        try
        {
            if ( browser == null )
            {
                browser = table.getBTree().browse();
            }

            browser.afterLast();
            clearValue();
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
        catch ( KeyNotFoundException knfe )
        {
            throw new CursorException( knfe );
        }
    }


    /**
     * {@inheritDoc}
     */
    public boolean first() throws LdapException, CursorException
    {
        beforeFirst();

        return next();
    }


    /**
     * {@inheritDoc}
     */
    public boolean last() throws LdapException, CursorException
    {
        afterLast();
        return previous();
    }


    /**
     * {@inheritDoc}
     */
    public boolean previous() throws LdapException, CursorException
    {
        checkNotClosed();
        if ( browser == null )
        {
            afterLast();
        }

        try
        {
            if ( browser.hasPrev() )
            {
                org.apache.directory.mavibot.btree.Tuple<K, V> tuple = browser.prev();

                returnedTuple.setKey( tuple.getKey() );
                returnedTuple.setValue( tuple.getValue() );
                valueAvailable = true;
                return true;
            }
            else
            {
                clearValue();
                return false;
            }
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
    }


    /**
     * {@inheritDoc}
     */
    public boolean next() throws LdapException, CursorException
    {
        checkNotClosed();

        if ( browser == null )
        {
            beforeFirst();
        }

        try
        {
            if ( browser.hasNext() )
            {
                org.apache.directory.mavibot.btree.Tuple<K, V> tuple = browser.next();

                returnedTuple.setKey( tuple.getKey() );
                returnedTuple.setValue( tuple.getValue() );
                valueAvailable = true;
                return true;
            }
            else
            {
                clearValue();
                return false;
            }
        }
        catch ( IOException e )
        {
            throw new CursorException( e );
        }
    }


    /**
     * {@inheritDoc}
     */
    public Tuple<K, V> get() throws CursorException
    {
        checkNotClosed();
        if ( valueAvailable )
        {
            return returnedTuple;
        }

        throw new InvalidCursorPositionException();
    }


    /**
     * {@inheritDoc}
     */
    @Override
    public void close() throws IOException
    {
        LOG_CURSOR.debug( "Closing MavibotCursor {}", this );
        super.close();
        closeBrowser( browser );
    }


    /**
     * {@inheritDoc}
     */
    @Override
    public void close( Exception cause ) throws IOException
    {
        LOG_CURSOR.debug( "Closing MavibotCursor {}", this );
        super.close( cause );
        closeBrowser( browser );
    }


    /**
     * Close the browser
     */
    private void closeBrowser( TupleCursor<K, V> browser )
    {
        if ( browser != null )
        {
            browser.close();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



