gr.uoa.di.madgik.grs.store.record
Class FileRecordStore

java.lang.Object
  extended by gr.uoa.di.madgik.grs.store.record.FileRecordStore
All Implemented Interfaces:
IRecordStore

public class FileRecordStore
extends java.lang.Object
implements IRecordStore

Implementation of the IRecordStore using a RandomAccessFile over a local file as the persistency medium

Author:
gpapanikos

Constructor Summary
FileRecordStore()
          Creates a new instance
 
Method Summary
 void dispose()
          Disposes the IRecordStore instance as well as any permanent storage resources occupied
 void enableOrder(boolean enableOrder)
          Whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not
 long getRecordCount()
          Retrieves the number of Records stored using this IRecordStore
 void persist(Record record)
          Persists the provided Record
 Record retrieve(long recordID, boolean reset)
          Retrieves a previously stored Record based on its id
 Record retrieveByIndex(long recordIndex, boolean reset)
          Retrieve a previously stored Record based on the index by which it was stored.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileRecordStore

public FileRecordStore()
                throws java.io.IOException
Creates a new instance

Throws:
java.io.IOException
Method Detail

enableOrder

public void enableOrder(boolean enableOrder)
Whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not

Specified by:
enableOrder in interface IRecordStore
Parameters:
enableOrder - whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not
See Also:
IRecordStore.enableOrder(boolean)

getRecordCount

public long getRecordCount()
Retrieves the number of Records stored using this IRecordStore

Specified by:
getRecordCount in interface IRecordStore
Returns:
the number of Records stored
See Also:
IRecordStore.getRecordCount()

dispose

public void dispose()
             throws GRS2RecordStoreException
Disposes the IRecordStore instance as well as any permanent storage resources occupied

Specified by:
dispose in interface IRecordStore
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed
See Also:
IRecordStore.dispose()

persist

public void persist(Record record)
             throws GRS2RecordStoreException
Persists the provided Record

Specified by:
persist in interface IRecordStore
Parameters:
record - the Record to persist
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed
See Also:
IRecordStore.persist(gr.uoa.di.madgik.grs.record.Record)

retrieve

public Record retrieve(long recordID,
                       boolean reset)
                throws GRS2RecordStoreException
Retrieves a previously stored Record based on its id

Specified by:
retrieve in interface IRecordStore
Parameters:
recordID - the ID of the Record to be retrieved
reset - whether during the Record.inflate(java.io.DataInput, boolean) invocation the reset parameter should be set to true or false
Returns:
the Record retrieved
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed
See Also:
IRecordStore.retrieve(long, boolean)

retrieveByIndex

public Record retrieveByIndex(long recordIndex,
                              boolean reset)
                       throws GRS2RecordStoreException
Retrieve a previously stored Record based on the index by which it was stored. This method is only available if before the first time a IRecordStore.persist(Record) was invoked the method IRecordStore.enableOrder(boolean) has been set to true

Specified by:
retrieveByIndex in interface IRecordStore
Parameters:
recordIndex - The index by which the Record to be retrieved was stored
reset - whether during the Record.inflate(java.io.DataInput, boolean) invocation the reset parameter should be set to true or false
Returns:
the Record retrieved
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed
See Also:
IRecordStore.retrieveByIndex(long, boolean)