messif.buckets.index
Enum LocalAbstractObjectOrder

java.lang.Object
  extended by java.lang.Enum<LocalAbstractObjectOrder>
      extended by messif.buckets.index.LocalAbstractObjectOrder
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<LocalAbstractObjectOrder>, java.util.Comparator<LocalAbstractObject>, IndexComparator<LocalAbstractObject,LocalAbstractObject>

public enum LocalAbstractObjectOrder
extends java.lang.Enum<LocalAbstractObjectOrder>
implements IndexComparator<LocalAbstractObject,LocalAbstractObject>, java.io.Serializable

Default orders of LocalAbstractObject based on attributes. Specifically, order can be defined on object IDs, locators, data or keys.


Enum Constant Summary
DATA
          Order defined by object data hash codes
KEY
          Order defined by object keys
LOCATOR
          Order defined by object locator URIs
UNIQUE_ID
          Order defined by object IDs
 
Field Summary
static IndexComparator<AbstractObjectKey,LocalAbstractObject> keyToLocalObjectComparator
          Index order defined by object keys
static OperationIndexComparator<java.lang.String> locatorToLocalObjectComparator
          Index order defined by object locators
static IndexComparator<java.lang.Comparable,java.lang.Object> trivialObjectComparator
           
static OperationIndexComparator<UniqueID> uniqueIDComparator
          Index order defined by object IDs
 
Method Summary
 int compare(LocalAbstractObject o1, LocalAbstractObject o2)
           
 LocalAbstractObject extractKey(LocalAbstractObject object)
          Returns the key (used for comparison) from an indexed object.
 int indexCompare(LocalAbstractObject o1, LocalAbstractObject o2)
          Compares its two arguments for order.
static
<T extends LocalAbstractObject>
T
searchIndexByKey(Index<T> index, AbstractObjectKey key)
          Search the specified index for the object with given key.
static
<T extends LocalAbstractObject>
T
searchIndexByLocator(Index<T> index, java.lang.String locator)
          Search the specified index for the object with given locator.
static
<T extends LocalAbstractObject>
T
searchIndexByObjectID(Index<T> index, UniqueID objectID)
          Search the specified index for the object with given ID.
static LocalAbstractObjectOrder valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static LocalAbstractObjectOrder[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface messif.buckets.index.IndexComparator
equals
 

Enum Constant Detail

UNIQUE_ID

public static final LocalAbstractObjectOrder UNIQUE_ID
Order defined by object IDs


LOCATOR

public static final LocalAbstractObjectOrder LOCATOR
Order defined by object locator URIs


DATA

public static final LocalAbstractObjectOrder DATA
Order defined by object data hash codes


KEY

public static final LocalAbstractObjectOrder KEY
Order defined by object keys

Field Detail

uniqueIDComparator

public static OperationIndexComparator<UniqueID> uniqueIDComparator
Index order defined by object IDs


locatorToLocalObjectComparator

public static OperationIndexComparator<java.lang.String> locatorToLocalObjectComparator
Index order defined by object locators


keyToLocalObjectComparator

public static IndexComparator<AbstractObjectKey,LocalAbstractObject> keyToLocalObjectComparator
Index order defined by object keys


trivialObjectComparator

public static IndexComparator<java.lang.Comparable,java.lang.Object> trivialObjectComparator
Method Detail

values

public static LocalAbstractObjectOrder[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (LocalAbstractObjectOrder c : LocalAbstractObjectOrder.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static LocalAbstractObjectOrder valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

indexCompare

public int indexCompare(LocalAbstractObject o1,
                        LocalAbstractObject o2)
Description copied from interface: IndexComparator
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Specified by:
indexCompare in interface IndexComparator<LocalAbstractObject,LocalAbstractObject>
Parameters:
o1 - the key to compare
o2 - the object to be compared
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compare

public int compare(LocalAbstractObject o1,
                   LocalAbstractObject o2)
Specified by:
compare in interface java.util.Comparator<LocalAbstractObject>

extractKey

public LocalAbstractObject extractKey(LocalAbstractObject object)
Description copied from interface: IndexComparator
Returns the key (used for comparison) from an indexed object.

Specified by:
extractKey in interface IndexComparator<LocalAbstractObject,LocalAbstractObject>
Parameters:
object - the indexed (full) object
Returns:
the extracted key

searchIndexByObjectID

public static <T extends LocalAbstractObject> T searchIndexByObjectID(Index<T> index,
                                                                      UniqueID objectID)
                                                           throws java.lang.IllegalStateException
Search the specified index for the object with given ID.

Type Parameters:
T - type of objects stored in the index
Parameters:
index - the index to search
objectID - the object ID to search for
Returns:
the object or null if it was not found in the index
Throws:
java.lang.IllegalStateException - if there was a problem reading objects from the index

searchIndexByLocator

public static <T extends LocalAbstractObject> T searchIndexByLocator(Index<T> index,
                                                                     java.lang.String locator)
                                                          throws java.lang.IllegalStateException
Search the specified index for the object with given locator.

Type Parameters:
T - type of objects stored in the index
Parameters:
index - the index to search
locator - the locator to search for
Returns:
the object or null if it was not found in the index
Throws:
java.lang.IllegalStateException - if there was a problem reading objects from the index

searchIndexByKey

public static <T extends LocalAbstractObject> T searchIndexByKey(Index<T> index,
                                                                 AbstractObjectKey key)
                                                      throws java.lang.IllegalStateException
Search the specified index for the object with given key.

Type Parameters:
T - type of objects stored in the index
Parameters:
index - the index to search
key - the key to search for
Returns:
the object or null if it was not found in the index
Throws:
java.lang.IllegalStateException - if there was a problem reading objects from the index