org.rutil.collection.trie
Class FileDataSourceCallback<VALUE_TYPE extends java.io.Serializable>

java.lang.Object
  extended by org.rutil.collection.trie.FileDataSourceCallback<VALUE_TYPE>
All Implemented Interfaces:
java.io.Serializable, DataSourceCallback<VALUE_TYPE>

public class FileDataSourceCallback<VALUE_TYPE extends java.io.Serializable>
extends java.lang.Object
implements DataSourceCallback<VALUE_TYPE>, java.io.Serializable

Author:
mohan
See Also:
Serialized Form

Constructor Summary
FileDataSourceCallback(SerializableObjectsFile<VALUE_TYPE> valueFile)
           
 
Method Summary
 boolean exists(long key)
          Check if the key exists
 VALUE_TYPE fetch(long key)
          Fetch the value associated with the given key.
 long save(VALUE_TYPE value)
          Saves the given value to the backing datastore and returns a unique key to reference this value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDataSourceCallback

public FileDataSourceCallback(SerializableObjectsFile<VALUE_TYPE> valueFile)
Method Detail

save

public long save(VALUE_TYPE value)
          throws java.lang.NullPointerException
Description copied from interface: DataSourceCallback
Saves the given value to the backing datastore and returns a unique key to reference this value.

Specified by:
save in interface DataSourceCallback<VALUE_TYPE extends java.io.Serializable>
Returns:
unique key that maps to the value
Throws:
java.lang.NullPointerException

fetch

public VALUE_TYPE fetch(long key)
Description copied from interface: DataSourceCallback
Fetch the value associated with the given key.

Specified by:
fetch in interface DataSourceCallback<VALUE_TYPE extends java.io.Serializable>
Returns:
value if a mapping exists for the given key or null

exists

public boolean exists(long key)
Description copied from interface: DataSourceCallback
Check if the key exists

Specified by:
exists in interface DataSourceCallback<VALUE_TYPE extends java.io.Serializable>
Returns:
true if the key exists, false otherwise.