sg.edu.nus.peer.info
Class IndexValue

java.lang.Object
  extended by sg.edu.nus.peer.info.IndexValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class IndexValue
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Implement an index key.

Version:
1.1 2006-3-6
Author:
Vu Quang Hieu, (Modified by) Xu Linhao, (Modified by) Vu Quang Hieu
See Also:
Serialized Form

Field Summary
static int COLUMN_INDEX
           
static int DATA_INDEX
           
 IndexInfo indexInfo
           
static IndexValue MAX_KEY
           
static IndexValue MIN_KEY
           
static int NUMERIC_TYPE
          The index key is numeric value type.
static int OFFSET
          Between the upper case and lower case, there are six additional characters, and hence when calculating the average value of two String we simply use this OFFSET value to adjust the median value of two characters.
static int RANGE_INDEX_TYPE
          The range index
static int STRING_TYPE
          The index key is character type.
static int TABLE_INDEX
           
static int TUPLE_INDEX_TYPE
          The tuple index
 
Constructor Summary
IndexValue(int type, java.lang.String newValue)
          Construct an index key with specified value.
IndexValue(int type, java.lang.String newValue, IndexInfo indexInfo)
           
IndexValue(java.lang.String serializeData)
          Construct an index value with a serialized string value.
 
Method Summary
static IndexValue average(IndexValue value1, IndexValue value2)
          Calculate the median value of two given IndexValues.
 int compareTo(java.lang.Object compareObject)
          Compares this object with the specified object for order.
 IndexInfo getIndexInfo()
          return index information
 java.lang.String getKey()
          Returns the key value.
static int getMaxIntValue()
          Return the maximum integer value of the index key.
static int getMinIntValue()
          Return the minimum integer value of the index key.
 java.lang.String getString()
          Return a readable string for testing or writing in the log file
 int getType()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUMERIC_TYPE

public static final int NUMERIC_TYPE
The index key is numeric value type.

See Also:
Constant Field Values

STRING_TYPE

public static final int STRING_TYPE
The index key is character type.

See Also:
Constant Field Values

TUPLE_INDEX_TYPE

public static final int TUPLE_INDEX_TYPE
The tuple index

See Also:
Constant Field Values

RANGE_INDEX_TYPE

public static final int RANGE_INDEX_TYPE
The range index

See Also:
Constant Field Values

TABLE_INDEX

public static final int TABLE_INDEX
See Also:
Constant Field Values

COLUMN_INDEX

public static final int COLUMN_INDEX
See Also:
Constant Field Values

DATA_INDEX

public static final int DATA_INDEX
See Also:
Constant Field Values

MIN_KEY

public static final IndexValue MIN_KEY

MAX_KEY

public static final IndexValue MAX_KEY

OFFSET

public static final int OFFSET
Between the upper case and lower case, there are six additional characters, and hence when calculating the average value of two String we simply use this OFFSET value to adjust the median value of two characters.

See Also:
Constant Field Values

indexInfo

public IndexInfo indexInfo
Constructor Detail

IndexValue

public IndexValue(int type,
                  java.lang.String newValue)
Construct an index key with specified value.

Parameters:
type - the type of the index key
newValue - the value of the index key

IndexValue

public IndexValue(int type,
                  java.lang.String newValue,
                  IndexInfo indexInfo)

IndexValue

public IndexValue(java.lang.String serializeData)
Construct an index value with a serialized string value.

Parameters:
serializeData - the serialized string value
Method Detail

getType

public int getType()

getKey

public java.lang.String getKey()
Returns the key value.

Returns:
returns the key value

compareTo

public int compareTo(java.lang.Object compareObject)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
compareObject - the object to be compared
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException

getMinIntValue

public static int getMinIntValue()
Return the minimum integer value of the index key.

Returns:
the minimum integer value of the index key

getMaxIntValue

public static int getMaxIntValue()
Return the maximum integer value of the index key.

Returns:
the maximum integer value of the index key

average

public static IndexValue average(IndexValue value1,
                                 IndexValue value2)
                          throws java.lang.ClassCastException
Calculate the median value of two given IndexValues.

Parameters:
value1 - the first index key
value2 - the second index key
Returns:
the median value
Throws:
java.lang.ClassCastException

getIndexInfo

public IndexInfo getIndexInfo()
return index information

Returns:
indexInfo

getString

public java.lang.String getString()
Return a readable string for testing or writing in the log file

Returns:
a readable string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object