uk.ac.leeds.ccg.andyt.projects.moses.io
Class HSARDataHandler

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.projects.moses.utilities.AbstractLog
      extended by uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractDataHandler
          extended by uk.ac.leeds.ccg.andyt.projects.moses.io.HSARDataHandler
All Implemented Interfaces:
java.io.Serializable

public class HSARDataHandler
extends AbstractDataHandler

For accessing HSARDataRecords and information about them.

See Also:
Serialized Form

Nested Class Summary
 class HSARDataHandler.AgeSex
          A simple class for distinguishing HSARDataRecord with _HRP = true into those with the same of _AGEH, _Sex
 
Field Summary
protected  java.util.HashMap _AgeSexHRP_HSARDataRecordVector_HashMap
          A collection providing a convenient way to access data for specific AgeSex classes for HRPs.
protected  java.util.HashMap _HID_HSARDataRecordVector_HashMap
          A collection providing a convenient way to access all other HSARDataRecords for a household with a given Household ID.
protected  HSARDataRecord[] _HSARDataRecordArray
          For storing all HSARDataRecords
 
Fields inherited from class uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractDataHandler
_Directory, _File, _RandomAccessFile, _RecordLength
 
Fields inherited from class uk.ac.leeds.ccg.andyt.projects.moses.utilities.AbstractLog
_Logger, _Logger_FileHandler
 
Constructor Summary
HSARDataHandler()
          Creates a new instance of HSARDataHandler
HSARDataHandler(java.io.File aFile)
          Creates a new instance of HSARDataHandler from aFile.
 
Method Summary
 void formatSource(java.io.File sourceFile, java.io.File formattedFile)
          Loads from source file
 java.util.HashMap get_AgeSexHRP_HSARDataRecordVector_HashMap()
           
 java.util.HashMap get_HID_HSARDataRecordVector_HashMap()
           
 java.util.HashMap get_ID_RecordID_HashMap()
          Method to be used to look up ISARDataRecord from ISARDataRecord._ID.
 AbstractDataRecord getDataRecord(long aRecordID)
           
 HSARDataRecord getHSARDataRecord(long aRecordID)
           
 HSARDataRecord getHSARDataRecord(java.util.Random aRandom)
           
 HSARDataRecord getHSARDataRecord(java.util.Random aRandom, HSARDataHandler.AgeSex aAgeSex)
           
 java.util.Vector getHSARDataRecords(HSARDataRecord[] tHPHRPs)
           
 java.util.Vector getHSARDataRecords(java.util.Vector tHPHRPRecordIDs)
           
 java.util.HashSet getHSARDataRecordsHashSet(java.util.HashSet aHPHRPHSARDataRecordsHashSet)
           
 java.util.Vector getHSARDataRecordsVector(HSARDataRecord aHRPHSARDataRecord)
           
 java.util.Vector getHSARDataRecordsVectors(java.util.HashSet aHRPHSARDataRecordsHashSet)
           
 long getNDataRecords()
           
 void loadIntoCache()
          Loads HSARDataRecords into the cache.
 
Methods inherited from class uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractDataHandler
get_Directory, get_RecordLength, init, init, load, print
 
Methods inherited from class uk.ac.leeds.ccg.andyt.projects.moses.utilities.AbstractLog
init_Logger, init_Logger, init_Logger, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_HSARDataRecordArray

protected HSARDataRecord[] _HSARDataRecordArray
For storing all HSARDataRecords


_AgeSexHRP_HSARDataRecordVector_HashMap

protected java.util.HashMap _AgeSexHRP_HSARDataRecordVector_HashMap
A collection providing a convenient way to access data for specific AgeSex classes for HRPs. Keys are AgeSex. Values are Vectors of HSARDataRecords.


_HID_HSARDataRecordVector_HashMap

protected java.util.HashMap _HID_HSARDataRecordVector_HashMap
A collection providing a convenient way to access all other HSARDataRecords for a household with a given Household ID. Keys are integer HID. Values are Vectors (of HSARDataRecords) with the first being the Household Reference Person.

Constructor Detail

HSARDataHandler

public HSARDataHandler()
Creates a new instance of HSARDataHandler


HSARDataHandler

public HSARDataHandler(java.io.File aFile)
Creates a new instance of HSARDataHandler from aFile.

Parameters:
aFile -
Method Detail

formatSource

public void formatSource(java.io.File sourceFile,
                         java.io.File formattedFile)
                  throws java.io.IOException
Loads from source file

Throws:
java.io.IOException

loadIntoCache

public void loadIntoCache()
Loads HSARDataRecords into the cache.


getDataRecord

public AbstractDataRecord getDataRecord(long aRecordID)
Specified by:
getDataRecord in class AbstractDataHandler
Parameters:
aRecordID - The RecordID of the HSARDataRecord to be returned.
Returns:
An AbstractDataRecord for the given RecordID

getHSARDataRecord

public HSARDataRecord getHSARDataRecord(long aRecordID)
Parameters:
aRecordID - The RecordID of the HSARDataRecord to be returned.

getHSARDataRecord

public HSARDataRecord getHSARDataRecord(java.util.Random aRandom)
Parameters:
aRandom - The Random used to select.
Returns:
A pseudo random HRP HSARDataRecord.

getHSARDataRecordsVector

public java.util.Vector getHSARDataRecordsVector(HSARDataRecord aHRPHSARDataRecord)
Parameters:
aHRPHSARDataRecord -
Returns:
A Vector of HSARDataRecords for the Household which contains aHRPHSARDataRecord.

getHSARDataRecordsVectors

public java.util.Vector getHSARDataRecordsVectors(java.util.HashSet aHRPHSARDataRecordsHashSet)
Parameters:
aHRPHSARDataRecordsHashSet - A HashSet of HSARDataRecords for HRP for the HSARDataRecords returned in the Vector of Vectors
Returns:
A Vector of Vectors of HSARDataRecords for the Households with HRP as in aHRPHSARDataRecordsHashSet

getHSARDataRecordsHashSet

public java.util.HashSet getHSARDataRecordsHashSet(java.util.HashSet aHPHRPHSARDataRecordsHashSet)
Returns:
All HSARDataRecords in a HashSet for those HRP in aHPHRPHSARDataRecordsHashSet

getHSARDataRecords

public java.util.Vector getHSARDataRecords(HSARDataRecord[] tHPHRPs)
Returns:
All HSARDataRecords for the Households with HRPs as in HSARDataRecord[] tHPHRPs

getHSARDataRecords

public java.util.Vector getHSARDataRecords(java.util.Vector tHPHRPRecordIDs)
Returns:
All HSARDataRecords for the Households with HRPs as in Vector tHPHRPs

getHSARDataRecord

public HSARDataRecord getHSARDataRecord(java.util.Random aRandom,
                                        HSARDataHandler.AgeSex aAgeSex)
Returns:
A pseudo random HSARDataRecord with AgeSex as in aAgeSex.

get_AgeSexHRP_HSARDataRecordVector_HashMap

public java.util.HashMap get_AgeSexHRP_HSARDataRecordVector_HashMap()

get_HID_HSARDataRecordVector_HashMap

public java.util.HashMap get_HID_HSARDataRecordVector_HashMap()

get_ID_RecordID_HashMap

public java.util.HashMap get_ID_RecordID_HashMap()
Method to be used to look up ISARDataRecord from ISARDataRecord._ID.

Returns:
a HashMap for looking up RecordID from ID

getNDataRecords

public long getNDataRecords()
Overrides:
getNDataRecords in class AbstractDataHandler
Returns:
The number of AbstractDataRecords in this.tRandomAccessFile