org.helidb.search
Class SearchMode

java.lang.Object
  extended by org.helidb.search.SearchMode

public class SearchMode
extends Object

This class defines constants for all search modes supported by the different databases. A database or database backend may inherit this class or create new instances of it to define its own search modes.

Since:
1.1
Author:
Karl Gustafsson
In_jar:
helidb-core

Field Summary
static SearchMode CLOSEST_ABOVE
          Search for an exact match or the closest key value greater than the search key.
static SearchMode CLOSEST_BELOW
          Search for an exact match or the closest key value less than the search key.
static SearchMode CLOSEST_MATCH
          Search for the closest match.
static SearchMode EXACT_MATCH
          Search for an exact match.
 
Constructor Summary
SearchMode(String tag)
          Create a new search mode.
 
Method Summary
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXACT_MATCH

public static final SearchMode EXACT_MATCH
Search for an exact match.


CLOSEST_MATCH

public static final SearchMode CLOSEST_MATCH
Search for the closest match. If there are two keys with the same distance from the search key, any of them may be returned.

This search mode requires that the compareTo method used (either from the database keys themselves or from a custom Comparator used for the search) return the distance between two compared objects. This means that Number types such as Integer or Long cannot be compared without a custom Comparator since, even though Number is Comparable, the compareTo methods of Number objects do not return the distance between the compared objects.


CLOSEST_BELOW

public static final SearchMode CLOSEST_BELOW
Search for an exact match or the closest key value less than the search key.

This search mode requires that the compareTo method used (either from the database keys themselves or from a custom Comparator used for the search) return the distance between two compared objects. This means that Number types such as Integer or Long cannot be compared without a custom Comparator since, even though Number is Comparable, the compareTo methods of Number objects do not return the distance between the compared objects.


CLOSEST_ABOVE

public static final SearchMode CLOSEST_ABOVE
Search for an exact match or the closest key value greater than the search key.

This search mode requires that the compareTo method used (either from the database keys themselves or from a custom Comparator used for the search) return the distance between two compared objects. This means that Number types such as Integer or Long cannot be compared without a custom Comparator since, even though Number is Comparable, the compareTo methods of Number objects do not return the distance between the compared objects.

Constructor Detail

SearchMode

public SearchMode(String tag)
Create a new search mode. This should only be done to define a new search mode supported by a database. Database clients should only use predefined search mode constants.

Parameters:
tag - A descriptive tag that is returned from the toString() method.
Method Detail

toString

public String toString()
Overrides:
toString in class Object