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

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.AbstractCASDataHandler
              extended by uk.ac.leeds.ccg.andyt.projects.moses.io.ToyModelDataHandler
All Implemented Interfaces:
java.io.Serializable

public class ToyModelDataHandler
extends AbstractCASDataHandler

A specialist handler for accessing CASKS002Records and information about the collection.

See Also:
Serialized Form

Field Summary
 java.io.FileOutputStream _ToyModelFileOutputStream
          A reference to a FileOutputStream for writing data
 
Fields inherited from class uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractCASDataHandler
_CAS001DataHandler, _CAS003DataHandler, _LookUpMSOAfromOAHashMap, _RecordIDZoneCodeHashMap
 
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
ToyModelDataHandler()
          Creates a new instance of ToyModelDataHandler
ToyModelDataHandler(ToyModelDataRecord_1 _ToyModelDataRecord_1, java.io.File _FormattedFile)
          Creates a new ToyModelDataHandler for Records loaded from infile.
ToyModelDataHandler(ToyModelDataRecord _ToyModelDataRecord, java.io.File _FormattedFile)
          Creates a new ToyModelDataHandler for Records loaded from infile.
 
Method Summary
 java.util.HashSet _Format_ToyModelDataRecord_1CSV_To_ToyModelDataRecord_2DAT(java.io.File _ToyModelDataRecord1CSVFile)
          Formats the ToyModelDataRecord_1 File file.
protected  void _FormatToyModelDataRecord_1(java.io.File file)
          Formats the ToyModelDataRecord_1 File file.
 AbstractCASDataRecord getDataRecord(long RecordID)
           
protected  ToyModelDataRecord_1 getToyModelDataRecord1(long RecordID)
           
static void main(java.lang.String[] args)
           
protected  int parseInt(java.lang.String string)
           
 long[] write1(ISARDataRecord[] aISARDataRecords, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID, java.util.Random random)
          Writes out ToyModel output via this._ToyModelFileOutputStream
 long[] write2_HSARHP_ISARCEP(java.lang.Object[] populations, HSARDataHandler tHSARDataHandler, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output via this._ToyModelFileOutputStream
 long[] write2_HSARHP(HSARDataRecord aHSARDataRecord, CASDataRecord_1 _CASDataRecord_1, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output type 2 via this._ToyModelFileOutputStream
 long[] write2_HSARHP(HSARDataRecord aHSARDataRecord, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output type 2 via this._ToyModelFileOutputStream
 long[] write2_ISARCEP(ISARDataRecord aISARDataRecord, CASDataRecord_1 _CASDataRecord_1, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output type 2 via this._ToyModelFileOutputStream
 long[] write2_ISARCEP(ISARDataRecord aISARDataRecord, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output type 2 via this._ToyModelFileOutputStream
 void write2_ISARHP_ISARCEP(java.lang.Object[] population, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output via this._ToyModelFileOutputStream.
 long[] write2_ISARHP_ISARCEP(java.util.Random tRandom, java.lang.Object[] population, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output via this._ToyModelFileOutputStream
 long[] write2_ISARHP(ISARDataRecord aISARDataRecord, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output type 2 via this._ToyModelFileOutputStream
 long[] write2_SWR_HSARHP_ISARCEP(java.lang.Object[] population, HSARDataHandler tHSARDataHandler, CASDataRecord_1 _CASDataRecord_1, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output via this._ToyModelFileOutputStream
 long[] write2_SWR_HSARHP_ISARCEP(java.lang.Object[] population, HSARDataHandler tHSARDataHandler, CASDataRecord aCASDataRecord, java.math.BigDecimal fitness, long[] aPersonIDHouseholdID)
          Writes out ToyModel output via this._ToyModelFileOutputStream
 
Methods inherited from class uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractCASDataHandler
get_LookUpMSOAfromOAHashMap, getCAS001DataHandler, getCAS003DataHandler, getDataRecord, getDataRecord, getLADCodes_TreeSet, getMSOACodes_HashSet, getMSOACodes_HashSet, getOACodes_HashSet, getOACodes_HashSet, getOACodes_TreeSet, getRecordIDZoneCode_HashMap, getRecordIDZoneCodeHashMap, getZoneCodeRecordID_HashMap, parseLine, printOAMSOACodes, write
 
Methods inherited from class uk.ac.leeds.ccg.andyt.projects.moses.io.AbstractDataHandler
get_Directory, get_RecordLength, getNDataRecords, 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

_ToyModelFileOutputStream

public java.io.FileOutputStream _ToyModelFileOutputStream
A reference to a FileOutputStream for writing data

Constructor Detail

ToyModelDataHandler

public ToyModelDataHandler()
Creates a new instance of ToyModelDataHandler


ToyModelDataHandler

public ToyModelDataHandler(ToyModelDataRecord_1 _ToyModelDataRecord_1,
                           java.io.File _FormattedFile)
                    throws java.io.IOException
Creates a new ToyModelDataHandler for Records loaded from infile.

Parameters:
_FormattedFile - Formatted File of ToyModelDataRecords
Throws:
java.io.IOException

ToyModelDataHandler

public ToyModelDataHandler(ToyModelDataRecord _ToyModelDataRecord,
                           java.io.File _FormattedFile)
                    throws java.io.IOException
Creates a new ToyModelDataHandler for Records loaded from infile.

Parameters:
_FormattedFile - Formatted File of ToyModelDataRecords
Throws:
java.io.IOException
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments

_FormatToyModelDataRecord_1

protected void _FormatToyModelDataRecord_1(java.io.File file)
Formats the ToyModelDataRecord_1 File file.

Parameters:
file - The ToyModelDataRecord_1 csv File to be formatted for RandomAccess.

_Format_ToyModelDataRecord_1CSV_To_ToyModelDataRecord_2DAT

public java.util.HashSet _Format_ToyModelDataRecord_1CSV_To_ToyModelDataRecord_2DAT(java.io.File _ToyModelDataRecord1CSVFile)
Formats the ToyModelDataRecord_1 File file.

Parameters:
_ToyModelDataRecord1CSVFile - The ToyModelDataRecord_1 csv File to be formatted for RandomAccess.
Returns:
A HashSet of _ZoneCodes.

getDataRecord

public AbstractCASDataRecord getDataRecord(long RecordID)
Specified by:
getDataRecord in class AbstractCASDataHandler
Parameters:
RecordID - The RecordID of the ISAR to be returned.
Returns:
An AbstractCASDataRecord for the given RecordID

parseInt

protected int parseInt(java.lang.String string)

getToyModelDataRecord1

protected ToyModelDataRecord_1 getToyModelDataRecord1(long RecordID)
                                               throws java.io.IOException
Parameters:
RecordID - The RecordID of the ToyModelDataRecord to be returned.
Throws:
java.io.IOException

write1

public long[] write1(ISARDataRecord[] aISARDataRecords,
                     CASDataRecord aCASDataRecord,
                     java.math.BigDecimal fitness,
                     long[] aPersonIDHouseholdID,
                     java.util.Random random)
              throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream

Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_SWR_HSARHP_ISARCEP

public long[] write2_SWR_HSARHP_ISARCEP(java.lang.Object[] population,
                                        HSARDataHandler tHSARDataHandler,
                                        CASDataRecord aCASDataRecord,
                                        java.math.BigDecimal fitness,
                                        long[] aPersonIDHouseholdID)
                                 throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream

Parameters:
population - A set of populations where:
  • population[0] are HSARDataRecords of constrained Household Population HRPs;
  • population[1] are HSARDataRecords of additional Household Population HRPs;
  • population[2] are ISARDataRecords of Communal Establishment Population
Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_SWR_HSARHP_ISARCEP

public long[] write2_SWR_HSARHP_ISARCEP(java.lang.Object[] population,
                                        HSARDataHandler tHSARDataHandler,
                                        CASDataRecord_1 _CASDataRecord_1,
                                        java.math.BigDecimal fitness,
                                        long[] aPersonIDHouseholdID)
                                 throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream

Parameters:
population - A set of populations where:
  • population[0] are HSARDataRecords of constrained Household Population HRPs;
  • population[1] are HSARDataRecords of additional Household Population HRPs;
  • population[2] are ISARDataRecords of Communal Establishment Population
Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_HSARHP_ISARCEP

public long[] write2_HSARHP_ISARCEP(java.lang.Object[] populations,
                                    HSARDataHandler tHSARDataHandler,
                                    CASDataRecord aCASDataRecord,
                                    java.math.BigDecimal fitness,
                                    long[] aPersonIDHouseholdID)
                             throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream

Parameters:
populations - A set of populations where:
  • population[0] are HSARDataRecords of constrained Household Population HRPs;
  • population[1] are HSARDataRecords of additional Household Population HRPs;
  • population[2] are ISARDataRecords of Communal Establishment Population
Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_ISARHP_ISARCEP

public long[] write2_ISARHP_ISARCEP(java.util.Random tRandom,
                                    java.lang.Object[] population,
                                    CASDataRecord aCASDataRecord,
                                    java.math.BigDecimal fitness,
                                    long[] aPersonIDHouseholdID)
                             throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream

Parameters:
population - A set of populations where:
  • population[0] are ISARDataRecords of Household Population HRPs;
  • population[1] are ISARDataRecords of Communal Establishment Population
Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_ISARHP_ISARCEP

public void write2_ISARHP_ISARCEP(java.lang.Object[] population,
                                  CASDataRecord aCASDataRecord,
                                  java.math.BigDecimal fitness,
                                  long[] aPersonIDHouseholdID)
                           throws java.io.IOException
Writes out ToyModel output via this._ToyModelFileOutputStream. The format is String,String,Long representing Area_Code, CEP or HP depending on whether the record represents part of the Communal Establishment Population or the Household Population, and the ISAR ID for the individual. This output does not indicate household or communal establishment groups.

Parameters:
population - A set of populations where:
  • population[0] are ISARDataRecords of Household Population HRPs;
  • population[1] are ISARDataRecords of Communal Establishment Population
Throws:
java.io.IOException

write2_ISARCEP

public long[] write2_ISARCEP(ISARDataRecord aISARDataRecord,
                             CASDataRecord aCASDataRecord,
                             java.math.BigDecimal fitness,
                             long[] aPersonIDHouseholdID)
                      throws java.io.IOException
Writes out ToyModel output type 2 via this._ToyModelFileOutputStream

Parameters:
aISARDataRecord - The ISARDataRecord.
aCASDataRecord - The CASDataRecord.
fitness - The BigDecimal.
aPersonIDHouseholdID - A long[].
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_ISARCEP

public long[] write2_ISARCEP(ISARDataRecord aISARDataRecord,
                             CASDataRecord_1 _CASDataRecord_1,
                             java.math.BigDecimal fitness,
                             long[] aPersonIDHouseholdID)
                      throws java.io.IOException
Writes out ToyModel output type 2 via this._ToyModelFileOutputStream

Parameters:
aISARDataRecord - The ISARDataRecord.
_CASDataRecord_1 - The CASDataRecord.
fitness - The BigDecimal.
aPersonIDHouseholdID - A long[].
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_ISARHP

public long[] write2_ISARHP(ISARDataRecord aISARDataRecord,
                            CASDataRecord aCASDataRecord,
                            java.math.BigDecimal fitness,
                            long[] aPersonIDHouseholdID)
                     throws java.io.IOException
Writes out ToyModel output type 2 via this._ToyModelFileOutputStream

Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_HSARHP

public long[] write2_HSARHP(HSARDataRecord aHSARDataRecord,
                            CASDataRecord aCASDataRecord,
                            java.math.BigDecimal fitness,
                            long[] aPersonIDHouseholdID)
                     throws java.io.IOException
Writes out ToyModel output type 2 via this._ToyModelFileOutputStream

Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException

write2_HSARHP

public long[] write2_HSARHP(HSARDataRecord aHSARDataRecord,
                            CASDataRecord_1 _CASDataRecord_1,
                            java.math.BigDecimal fitness,
                            long[] aPersonIDHouseholdID)
                     throws java.io.IOException
Writes out ToyModel output type 2 via this._ToyModelFileOutputStream

Returns:
long[] result
  • result[0] is the next sequential personID
  • result[1] is the next sequential householdID
Throws:
java.io.IOException