org.apache.directory.server.core.partition.impl.btree.jdbm
Class KeyTupleAvlCursor<K,V>

java.lang.Object
  extended by org.apache.directory.server.xdbm.AbstractTupleCursor<K,V>
      extended by org.apache.directory.server.core.partition.impl.btree.jdbm.KeyTupleAvlCursor<K,V>
All Implemented Interfaces:
java.lang.Iterable<Tuple<K,V>>, Cursor<Tuple<K,V>>, TupleCursor<K,V>

public class KeyTupleAvlCursor<K,V>
extends AbstractTupleCursor<K,V>

Cursor over a set of values for the same key which are store in an in memory AvlTree. This Cursor is limited to the same key and it's tuples will always return the same key.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Constructor Summary
KeyTupleAvlCursor(AvlTree<V> avlTree, K key)
          Creates a Cursor over the tuples of an AvlTree.
 
Method Summary
 void after(Tuple<K,V> element)
          Prepares this Cursor, so a subsequent call to Cursor#previous() with a true return value, will have positioned the Cursor on a dataset element equal to or less than the element argument but not greater.
 void afterKey(K key)
          An alternative to calling after(Tuple) which often may require wrapping a key in a newly created Tuple object that may be unnecessary.
 void afterLast()
          Positions this Curser after the last element.
 void afterValue(K key, V value)
          An alternative to calling after(Tuple) which often may require wrapping a key and a value in a newly created Tuple object that may be unnecessary.
 boolean available()
          Determines whether or not a call to get() will succeed.
 void before(Tuple<K,V> element)
          Positions this Cursor over the same keys before the value of the supplied element Tuple.
 void beforeFirst()
          Positions this Curser before the first element.
 void beforeKey(K key)
          An alternative to calling before(Tuple) which often may require wrapping a key in a newly created Tuple object that may be unnecessary.
 void beforeValue(K key, V value)
          An alternative to calling before(Tuple) which often may require wrapping a key and a value in a newly created Tuple object that may be unnecessary.
 boolean first()
          Positions this Curser at the first element.
 Tuple<K,V> get()
          Gets the object at the current position.
 boolean isElementReused()
          Gets whether or not this Cursor will return the same element object instance on get() operations for any position of this Cursor.
 boolean last()
          Positions this Curser at the last element.
 boolean next()
          Advances this Cursor to the next position.
 boolean previous()
          Advances this Cursor to the previous position.
 
Methods inherited from class org.apache.directory.server.xdbm.AbstractTupleCursor
checkNotClosed, close, close, isClosed, iterator, setClosureMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyTupleAvlCursor

public KeyTupleAvlCursor(AvlTree<V> avlTree,
                         K key)
Creates a Cursor over the tuples of an AvlTree.

Parameters:
avlTree - the AvlTree to build a Tuple returning Cursor over
key - the constant key for which values are returned
Method Detail

available

public boolean available()
Description copied from interface: Cursor
Determines whether or not a call to get() will succeed.

Returns:
true if the cursor is valid get() will succeed, false otherwise

beforeKey

public void beforeKey(K key)
               throws java.lang.Exception
Description copied from interface: TupleCursor
An alternative to calling before(Tuple) which often may require wrapping a key in a newly created Tuple object that may be unnecessary. This method behaves just like before(Tuple) except it advances to just before the first value of the key.

Parameters:
key - the key to advance just before
Throws:
java.lang.Exception - if there are faults peforming this operation

afterKey

public void afterKey(K key)
              throws java.lang.Exception
Description copied from interface: TupleCursor
An alternative to calling after(Tuple) which often may require wrapping a key in a newly created Tuple object that may be unnecessary. This method behaves just like after(Tuple) except it advances to just after the last value of the key.

Parameters:
key - the key to advance just after the last value
Throws:
java.lang.Exception - if there are faults peforming this operation

beforeValue

public void beforeValue(K key,
                        V value)
                 throws java.lang.Exception
Description copied from interface: TupleCursor
An alternative to calling before(Tuple) which often may require wrapping a key and a value in a newly created Tuple object that may be unnecessary. This method behaves just like before(Tuple) except it advances to just before the value of the key which may still be of the same key. This method will not be supported if duplicate keys are not supported. In this case an UnsupportedOperationException will be thrown.

Parameters:
key - the key of the value to advance just before
value - the value to advance just before
Throws:
java.lang.UnsupportedOperationException - if duplicate keys not supporrted
java.lang.Exception - if there are faults peforming this operation

afterValue

public void afterValue(K key,
                       V value)
                throws java.lang.Exception
Description copied from interface: TupleCursor
An alternative to calling after(Tuple) which often may require wrapping a key and a value in a newly created Tuple object that may be unnecessary. This method behaves just like after(Tuple) except it advances to just after the value with the specified key. This method will not be supported if duplicate keys are not supported. In this case an UnsupportedOperationException will be thrown.

Parameters:
key - the key of the value to advance just after
value - the value to advance just after
Throws:
java.lang.UnsupportedOperationException - if duplicate keys not supporrted
java.lang.Exception - if there are faults peforming this operation

before

public void before(Tuple<K,V> element)
            throws java.lang.Exception
Positions this Cursor over the same keys before the value of the supplied element Tuple. The supplied element Tuple's key is not considered at all.

Parameters:
element - the valueTuple who's value is used to position this Cursor
Throws:
java.lang.Exception - if there are failures to position the Cursor

after

public void after(Tuple<K,V> element)
           throws java.lang.Exception
Description copied from interface: Cursor
Prepares this Cursor, so a subsequent call to Cursor#previous() with a true return value, will have positioned the Cursor on a dataset element equal to or less than the element argument but not greater. A call to Cursor#next() with a true return value will position the Cursor on a dataset element greater than the argument. If Cursor#next() returns false then the Cursor is past the last element and so all values in the dataset are less than or equal to the argument. If Cursor#previous() returns false then the Cursor is positioned before the first element and all elements in the dataset are greater than the argument.

Parameters:
element - the element to be positioned after
Throws:
java.lang.Exception - if there are problems positioning this cursor or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

beforeFirst

public void beforeFirst()
                 throws java.lang.Exception
Description copied from interface: Cursor
Positions this Curser before the first element.

Throws:
java.lang.Exception - if there are problems positioning this cursor or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

afterLast

public void afterLast()
               throws java.lang.Exception
Description copied from interface: Cursor
Positions this Curser after the last element.

Throws:
java.lang.Exception - if there are problems positioning this Cursor or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

first

public boolean first()
              throws java.lang.Exception
Description copied from interface: Cursor
Positions this Curser at the first element.

Returns:
true if the position has been successfully changed to the first element, false otherwise
Throws:
java.lang.Exception - if there are problems positioning this Cursor or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

last

public boolean last()
             throws java.lang.Exception
Description copied from interface: Cursor
Positions this Curser at the last element.

Returns:
true if the position has been successfully changed to the last element, false otherwise
Throws:
java.lang.Exception - if there are problems positioning this Cursor or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

previous

public boolean previous()
                 throws java.lang.Exception
Description copied from interface: Cursor
Advances this Cursor to the previous position. If called before explicitly positioning this Cursor, the position is presumed to be after the last element and this method moves the cursor back to the last element.

Returns:
true if the advance succeeded, false otherwise
Throws:
java.lang.Exception - if there are problems advancing to the next position
java.lang.UnsupportedOperationException - if this method is not supported

next

public boolean next()
             throws java.lang.Exception
Description copied from interface: Cursor
Advances this Cursor to the next position. If called before explicitly positioning this Cursor, the position is presumed to be before the first element and this method moves the cursor forward to the first element.

Returns:
true if the advance succeeded, false otherwise
Throws:
java.lang.Exception - if there are problems advancing to this Cursor to the next position, or if this Cursor is closed
java.lang.UnsupportedOperationException - if this method is not supported

get

public Tuple<K,V> get()
               throws java.lang.Exception
Description copied from interface: Cursor
Gets the object at the current position. Cursor implementations may choose to reuse element objects by re-populating them on advances instead of creating new objects on each advance.

Returns:
the object at the current position
Throws:
java.lang.Exception - if the object at this Cursor's current position cannot be retrieved, or if this Cursor is closed

isElementReused

public boolean isElementReused()
Description copied from interface: Cursor
Gets whether or not this Cursor will return the same element object instance on get() operations for any position of this Cursor. Some Cursor implementations may reuse the same element copying values into it for every position rather than creating and emiting new element objects on each advance. Some Cursor implementations may return different elements for each position yet the same element instance is returned for the same position. In these cases this method should return true.

Returns:
true if elements are reused by this Cursor


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