org.apache.directory.server.core.partition.impl.btree
Class IndexCursorAdaptor<K,O,ID>

java.lang.Object
  extended by org.apache.directory.server.core.partition.impl.btree.IndexCursorAdaptor<K,O,ID>
All Implemented Interfaces:
java.lang.Iterable<IndexEntry<K,O,ID>>, IndexCursor<K,O,ID>, org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>

public class IndexCursorAdaptor<K,O,ID>
extends java.lang.Object
implements IndexCursor<K,O,ID>

A Cursor which adapts an underlying Tuple based Cursor to one which returns IndexEntry objects rather than tuples.

Version:
$Rev$
Author:
Apache Directory Project

Constructor Summary
IndexCursorAdaptor(org.apache.directory.shared.ldap.cursor.Cursor<Tuple> wrappedCursor, boolean forwardIndex)
          Creates an IndexCursorAdaptor which wraps and adapts a Cursor from a table to one which returns an IndexEntry.
 
Method Summary
 void after(IndexEntry<K,O,ID> element)
           
 void afterLast()
           
 void afterValue(ID id, K key)
          An alternative to calling after(IndexEntry) which often may require wrapping an id and value in a newly created IndexEntry object that may be an unnecessary object creation.
 boolean available()
           
 void before(IndexEntry<K,O,ID> element)
           
 void beforeFirst()
           
 void beforeValue(ID id, K key)
          An alternative to calling before(IndexEntry) which often may require wrapping an id and value in a newly created IndexEntry object that may be an unnecessary object creation.
 void close()
           
 void close(java.lang.Exception reason)
           
 boolean first()
           
 IndexEntry<K,O,ID> get()
           
 boolean isClosed()
           
 boolean isElementReused()
           
 java.util.Iterator<IndexEntry<K,O,ID>> iterator()
           
 boolean last()
           
 boolean next()
           
 boolean previous()
           
 void setClosureMonitor(org.apache.directory.shared.ldap.cursor.ClosureMonitor monitor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexCursorAdaptor

public IndexCursorAdaptor(org.apache.directory.shared.ldap.cursor.Cursor<Tuple> wrappedCursor,
                          boolean forwardIndex)
Creates an IndexCursorAdaptor which wraps and adapts a Cursor from a table to one which returns an IndexEntry.

Parameters:
wrappedCursor - the Cursor being adapted
forwardIndex - true for a cursor over a forward index, false for one over a reverse index
Method Detail

available

public boolean available()
Specified by:
available in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>

beforeValue

public void beforeValue(ID id,
                        K key)
                 throws java.lang.Exception
Description copied from interface: IndexCursor
An alternative to calling before(IndexEntry) which often may require wrapping an id and value in a newly created IndexEntry object that may be an unnecessary object creation. Some implementations may not support this operation and may throw an UnsupportedOperationEception.

Specified by:
beforeValue in interface IndexCursor<K,O,ID>
Parameters:
id - the id for the entry
key - the value to advance just before
Throws:
java.lang.Exception - if there are faults performing this operation

afterValue

public void afterValue(ID id,
                       K key)
                throws java.lang.Exception
Description copied from interface: IndexCursor
An alternative to calling after(IndexEntry) which often may require wrapping an id and value in a newly created IndexEntry object that may be an unnecessary object creation. Some implementations may not support this operation and may throw an UnsupportedOperationEception.

Specified by:
afterValue in interface IndexCursor<K,O,ID>
Parameters:
id - the id for the entry
key - the value to advance just after the last value
Throws:
java.lang.Exception - if there are faults performing this operation

before

public void before(IndexEntry<K,O,ID> element)
            throws java.lang.Exception
Specified by:
before in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

after

public void after(IndexEntry<K,O,ID> element)
           throws java.lang.Exception
Specified by:
after in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

beforeFirst

public void beforeFirst()
                 throws java.lang.Exception
Specified by:
beforeFirst in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

afterLast

public void afterLast()
               throws java.lang.Exception
Specified by:
afterLast in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

first

public boolean first()
              throws java.lang.Exception
Specified by:
first in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

last

public boolean last()
             throws java.lang.Exception
Specified by:
last in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

isClosed

public boolean isClosed()
                 throws java.lang.Exception
Specified by:
isClosed in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

previous

public boolean previous()
                 throws java.lang.Exception
Specified by:
previous in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

next

public boolean next()
             throws java.lang.Exception
Specified by:
next in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

get

public IndexEntry<K,O,ID> get()
                       throws java.lang.Exception
Specified by:
get in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

isElementReused

public boolean isElementReused()
Specified by:
isElementReused in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>

setClosureMonitor

public final void setClosureMonitor(org.apache.directory.shared.ldap.cursor.ClosureMonitor monitor)
Specified by:
setClosureMonitor in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>

close

public void close()
           throws java.lang.Exception
Specified by:
close in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

close

public void close(java.lang.Exception reason)
           throws java.lang.Exception
Specified by:
close in interface org.apache.directory.shared.ldap.cursor.Cursor<IndexEntry<K,O,ID>>
Throws:
java.lang.Exception

iterator

public java.util.Iterator<IndexEntry<K,O,ID>> iterator()
Specified by:
iterator in interface java.lang.Iterable<IndexEntry<K,O,ID>>


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.