org.opends.server.backends.jeb
Class EntryIDSet

java.lang.Object
  extended by org.opends.server.backends.jeb.EntryIDSet
All Implemented Interfaces:
java.lang.Iterable<EntryID>

public class EntryIDSet
extends java.lang.Object
implements java.lang.Iterable<EntryID>

Represents a set of Entry IDs. It can represent a set where the IDs are not defined, for example when the index entry limit has been exceeded.


Constructor Summary
EntryIDSet()
          Create a new undefined set.
EntryIDSet(byte[] keyBytes, byte[] bytes)
          Create a new entry ID set from the raw database value.
EntryIDSet(long size)
          Create a new undefined set with a initial size.
 
Method Summary
 boolean add(EntryID entryID)
          Insert an ID into this set.
 void addAll(EntryIDSet that)
          Add all the IDs from a given set that are not already present.
 boolean contains(EntryID entryID)
          Check whether this set of entry IDs contains a given ID.
 void deleteAll(EntryIDSet that)
          Delete all IDs in this set that are in a given set.
 boolean isDefined()
          Determine whether this set of IDs is defined.
 java.util.Iterator<EntryID> iterator()
          Create an iterator over the set or an empty iterator if the set is not defined.
 java.util.Iterator<EntryID> iterator(EntryID begin)
          Create an iterator over the set or an empty iterator if the set is not defined.
 boolean remove(EntryID entryID)
          Remove an ID from this set.
 void retainAll(EntryIDSet that)
          Takes the intersection of this set with another.
 long size()
          Get the size of this entry ID set.
 byte[] toDatabase()
          Get a database representation of this object.
 java.lang.String toString()
          Get a string representation of this object.
 void toString(java.lang.StringBuilder buffer)
          Convert to a short string to aid with debugging.
static EntryIDSet unionOfSets(java.util.ArrayList<EntryIDSet> sets, boolean allowDuplicates)
          Create a new set of entry IDs that is the union of several entry ID sets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntryIDSet

public EntryIDSet()
Create a new undefined set.


EntryIDSet

public EntryIDSet(long size)
Create a new undefined set with a initial size.

Parameters:
size - The undefined size for this set.

EntryIDSet

public EntryIDSet(byte[] keyBytes,
                  byte[] bytes)
Create a new entry ID set from the raw database value.

Parameters:
keyBytes - The database key that contains this value.
bytes - The database value, or null if there are no entry IDs.
Method Detail

unionOfSets

public static EntryIDSet unionOfSets(java.util.ArrayList<EntryIDSet> sets,
                                     boolean allowDuplicates)
Create a new set of entry IDs that is the union of several entry ID sets.

Parameters:
sets - A list of entry ID sets.
allowDuplicates - true if duplicate IDs are allowed in the resulting set, or if the provided sets are sure not to overlap; false if duplicates should be eliminated.
Returns:
The union of the provided entry ID sets.

size

public long size()
Get the size of this entry ID set.

Returns:
The number of IDs in the set.

toString

public java.lang.String toString()
Get a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.

toString

public void toString(java.lang.StringBuilder buffer)
Convert to a short string to aid with debugging.

Parameters:
buffer - The string is appended to this string builder.

isDefined

public boolean isDefined()
Determine whether this set of IDs is defined.

Returns:
true if the set of IDs is defined.

toDatabase

public byte[] toDatabase()
Get a database representation of this object.

Returns:
A database representation of this object as a byte array.

add

public boolean add(EntryID entryID)
Insert an ID into this set.

Parameters:
entryID - The ID to be inserted.
Returns:
true if the set was changed, false if it was not changed, for example if the set is undefined or the ID was already present.

remove

public boolean remove(EntryID entryID)
Remove an ID from this set.

Parameters:
entryID - The ID to be removed
Returns:
true if the set was changed, false if it was not changed, for example if the set was undefined or the ID was not present.

contains

public boolean contains(EntryID entryID)
Check whether this set of entry IDs contains a given ID.

Parameters:
entryID - The ID to be checked.
Returns:
true if this set contains the given ID, or if the set is undefined.

retainAll

public void retainAll(EntryIDSet that)
Takes the intersection of this set with another. Retain those IDs that appear in the given set.

Parameters:
that - The set of IDs that are to be retained from this object.

addAll

public void addAll(EntryIDSet that)
Add all the IDs from a given set that are not already present.

Parameters:
that - The set of IDs to be added. It MUST be defined

deleteAll

public void deleteAll(EntryIDSet that)
Delete all IDs in this set that are in a given set.

Parameters:
that - The set of IDs to be deleted. It MUST be defined.

iterator

public java.util.Iterator<EntryID> iterator()
Create an iterator over the set or an empty iterator if the set is not defined.

Specified by:
iterator in interface java.lang.Iterable<EntryID>
Returns:
An EntryID iterator.

iterator

public java.util.Iterator<EntryID> iterator(EntryID begin)
Create an iterator over the set or an empty iterator if the set is not defined.

Parameters:
begin - The entry ID of the first entry to return in the list.
Returns:
An EntryID iterator.