org.apache.directory.server.core.avltree
Class SingletonOrOrderedSet<V>

java.lang.Object
  extended by org.apache.directory.server.core.avltree.SingletonOrOrderedSet<V>

public class SingletonOrOrderedSet<V>
extends java.lang.Object

Stores either a single object or many of them in an AvlTree.

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

Constructor Summary
SingletonOrOrderedSet(AvlTree<V> orderedSet)
          Creates a new instance of SingletonOrOrderedSet with a set of ordered values.
SingletonOrOrderedSet(V singleton)
          Creates a new instance of SingletonOrOrderedSet with a singleton value.
 
Method Summary
 AvlTree<V> getOrderedSet()
          Gets the ordered set.
 V getSingleton()
          Gets the singleton value.
 boolean isOrderedSet()
          Gets whether or not the stored value is an ordered set.
 boolean isSingleton()
          Gets whether or not the stored value is a singleton.
 AvlTree<V> setOrderedSet(AvlTree<V> orderedSet)
          Sets the set of ordered values.
 V setSingleton(V singleton)
          Sets the singleton if in singleton mode.
 V switchToOrderedSet(AvlTree<V> orderedSet)
          Switches from orderedSet mode to singleton mode, while returning the singleton value before removing it forever.
 AvlTree<V> switchToSingleton(V singleton)
          Switches from orderedSet mode to singleton mode, while returning the ordered set of values before removing them forever.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonOrOrderedSet

public SingletonOrOrderedSet(V singleton)
Creates a new instance of SingletonOrOrderedSet with a singleton value.

Parameters:
singleton - the singleton value

SingletonOrOrderedSet

public SingletonOrOrderedSet(AvlTree<V> orderedSet)
Creates a new instance of SingletonOrOrderedSet with a set of ordered values.

Parameters:
orderedSet - the set of ordered values
Method Detail

isSingleton

public boolean isSingleton()
Gets whether or not the stored value is a singleton.

Returns:
true if in singleton mode, false otherwise

isOrderedSet

public boolean isOrderedSet()
Gets whether or not the stored value is an ordered set.

Returns:
true if in ordered set mode, false otherwise

getSingleton

public V getSingleton()
Gets the singleton value.

Returns:
the singleton value
Throws:
java.lang.RuntimeException - if not in singleton mode

setSingleton

public V setSingleton(V singleton)
Sets the singleton if in singleton mode.

Parameters:
singleton - the singleton value to set
Returns:
old single value

switchToSingleton

public AvlTree<V> switchToSingleton(V singleton)
Switches from orderedSet mode to singleton mode, while returning the ordered set of values before removing them forever.

Parameters:
singleton - the singleton value
Returns:
the set of ordered values before nulling it out
Throws:
java.lang.RuntimeException - if already in singleton mode

getOrderedSet

public AvlTree<V> getOrderedSet()
Gets the ordered set.

Returns:
the ordered set
Throws:
java.lang.RuntimeException - if in singleton mode

setOrderedSet

public AvlTree<V> setOrderedSet(AvlTree<V> orderedSet)
Sets the set of ordered values.

Parameters:
orderedSet - the set of ordered values to use
Returns:
the old set of ordered values
Throws:
java.lang.RuntimeException - if in singleton mode

switchToOrderedSet

public V switchToOrderedSet(AvlTree<V> orderedSet)
Switches from orderedSet mode to singleton mode, while returning the singleton value before removing it forever.

Parameters:
orderedSet - the AvlTree to use for orderedSet of values
Returns:
the singleton to return before nulling it out
Throws:
java.lang.RuntimeException - if the mode is already in orderedSet mode.


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