iitb.con.ds
Interface ItemTable<K1,K2,V>

All Known Implementing Classes:
InstanceTable, TypeTable

public interface ItemTable<K1,K2,V>

ItemTable is table like structure to have key-value pairs. It has two keys : Super Key (K1) and Sub Key (K2). The implementor can use this according to their need. Basically is will be implemented with Hash structure. It provides operations to put and get the objects based on their keys.


Method Summary
 void close()
          Close the file associate with the table
 void commit()
          Commits the table contents to the file
 java.util.Map<K2,V> get(K1 k1)
          Gets the object based on sub key
 V get(K1 k1, K2 k2)
          Gets the object based on super and sub key
 V get(K2 k2)
          Gets the object based on sub key
 java.util.List<V> getAllItems()
          Returns all the items in the table
 java.lang.Object getObject(java.lang.Object o)
          Gets the object from the table.
 void put(K1 k1, K2 k2, V v)
          Puts the object based on the super and sub key
 void put(K1 k1, V v)
          Puts the object based on the super key
 void put(V v)
          Puts the object into the table
 boolean remove(K1 k1, K2 k2)
          Removes the item based on the super and sub key
 boolean remove(K2 k2)
          Removes the item based on the sub key
 int size()
          Size of the table (number items in the table)
 

Method Detail

close

void close()
           throws java.io.IOException
Close the file associate with the table

Throws:
java.io.IOException - if file operations fail

commit

void commit()
            throws java.io.IOException
Commits the table contents to the file

Throws:
java.io.IOException - if file operations fail

get

java.util.Map<K2,V> get(K1 k1)
Gets the object based on sub key

Parameters:
k1 - super key
Returns:
value object

get

V get(K1 k1,
      K2 k2)
Gets the object based on super and sub key

Parameters:
k1 - super key
k2 - sub key
Returns:
value object

get

V get(K2 k2)
Gets the object based on sub key

Parameters:
k2 - sub key
Returns:
value object

getAllItems

java.util.List<V> getAllItems()
Returns all the items in the table

Returns:
Value objects as List

getObject

java.lang.Object getObject(java.lang.Object o)
Gets the object from the table. This is generic method allowing user to use custom key to get the value object

Parameters:
o - key object
Returns:
value object

put

void put(K1 k1,
         K2 k2,
         V v)
Puts the object based on the super and sub key

Parameters:
k1 - super key
k2 - sub key
v - value

put

void put(K1 k1,
         V v)
Puts the object based on the super key

Parameters:
k1 - super key
v - value

put

void put(V v)
Puts the object into the table


remove

boolean remove(K1 k1,
               K2 k2)
Removes the item based on the super and sub key

Parameters:
k1 - super key
k2 - sub key
Returns:
true on success

remove

boolean remove(K2 k2)
Removes the item based on the sub key

Parameters:
k2 - sub key
Returns:
true on success

size

int size()
Size of the table (number items in the table)

Returns:
table size