Package org.planit.output.formatter
Class CsvFileOutputFormatter
- java.lang.Object
-
- org.planit.output.formatter.BaseOutputFormatter
-
- org.planit.output.formatter.FileOutputFormatter
-
- org.planit.output.formatter.CsvFileOutputFormatter
-
- All Implemented Interfaces:
OutputFormatter
- Direct Known Subclasses:
CSVOutputFormatter
,PlanItOutputFormatter
public abstract class CsvFileOutputFormatter extends FileOutputFormatter
Class containing common methods required by classes which write results to CSV output files- Author:
- gman6028
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<OutputTypeEnum,List<String>>
csvFileNameMap
Map of list of CSV output file names for each OutputType-
Fields inherited from class org.planit.output.formatter.BaseOutputFormatter
id, initialCostsLocation, outputKeyProperties, outputTimeUnit, outputTypeKeysLocked, outputTypes, outputTypeValuesLocked, outputValueProperties
-
Fields inherited from interface org.planit.output.formatter.OutputFormatter
MEMORY_OUTPUT_FORMATTER, NOT_SPECIFIED, PLANIT_OUTPUT_FORMATTER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CsvFileOutputFormatter(IdGroupingToken groupId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCsvFileNamePerOutputType(OutputTypeEnum currentoutputType, String csvFileName)
Add a new name of the CSV output file for a specified output typeprotected org.apache.commons.csv.CSVPrinter
openCsvFileAndWriteHeaders(OutputTypeConfiguration outputTypeConfiguration, String csvFileName)
Open the CSV output file and write the headers to itprotected PlanItException
writeLinkResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the Link CSV file for the current iterationprotected PlanItException
writeOdResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the OD CSV file for the current iterationprotected PlanItException
writePathResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the Path CSV file for the current iteration-
Methods inherited from class org.planit.output.formatter.FileOutputFormatter
generateOutputFileName, generateOutputFileName
-
Methods inherited from class org.planit.output.formatter.BaseOutputFormatter
getId, getOutputTimeUnit, getOutputTimeUnitString, lockOutputProperties, persist, setOutputTimeUnit, writeGeneralResultsForCurrentTimePeriod, writeLinkResultsForCurrentTimePeriod, writeOdResultsForCurrentTimePeriod, writePathResultsForCurrentTimePeriod, writeSimulationResultsForCurrentTimePeriod
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.output.formatter.OutputFormatter
canHandleMultipleIterations, finaliseAfterSimulation, initialiseBeforeSimulation
-
-
-
-
Field Detail
-
csvFileNameMap
protected final Map<OutputTypeEnum,List<String>> csvFileNameMap
Map of list of CSV output file names for each OutputType
-
-
Constructor Detail
-
CsvFileOutputFormatter
protected CsvFileOutputFormatter(IdGroupingToken groupId)
Constructor- Parameters:
groupId
- , contiguous id generation within this group for instances of this class
-
-
Method Detail
-
writeOdResultsForCurrentTimePeriodToCsvPrinter
protected PlanItException writeOdResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the OD CSV file for the current iteration- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- output type configuration for the current output typecurrentOutputType
- the output typeoutputAdapter
- output adapter for the current output typemodes
- Set of modes for the current assignmenttimePeriod
- the current time periodcsvPrinter
- CSVPrinter object to record results for this iteration- Returns:
- PlanItException thrown if the CSV file cannot be created or written to
-
writePathResultsForCurrentTimePeriodToCsvPrinter
protected PlanItException writePathResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the Path CSV file for the current iteration- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- output type configuration for the current output typecurrentOutputType
- the output typeoutputAdapter
- output adapter for the current output typemodes
- Set of modes for the current assignmenttimePeriod
- the current time periodcsvPrinter
- CSVPrinter object to record results for this iteration- Returns:
- PlanItException thrown if the CSV file cannot be created or written to
-
writeLinkResultsForCurrentTimePeriodToCsvPrinter
protected PlanItException writeLinkResultsForCurrentTimePeriodToCsvPrinter(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, org.apache.commons.csv.CSVPrinter csvPrinter)
Write output values to the Link CSV file for the current iteration- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- the current output type configurationcurrentOutputType
- the output typeoutputAdapter
- output adapter for the current output typemodes
- Set of modes for the current assignmenttimePeriod
- the current time periodcsvPrinter
- CSVPrinter object to record results for this iteration- Returns:
- PlanItException thrown if the CSV file cannot be created or written to
-
openCsvFileAndWriteHeaders
protected org.apache.commons.csv.CSVPrinter openCsvFileAndWriteHeaders(OutputTypeConfiguration outputTypeConfiguration, String csvFileName) throws Exception
Open the CSV output file and write the headers to it- Parameters:
outputTypeConfiguration
- the current output type configurationcsvFileName
- the name of the CSV output file- Returns:
- the CSVPrinter object (output values will be written to this in subsequent rows)
- Throws:
Exception
- thrown if there is an error opening the file
-
addCsvFileNamePerOutputType
public void addCsvFileNamePerOutputType(OutputTypeEnum currentoutputType, String csvFileName)
Add a new name of the CSV output file for a specified output type- Parameters:
currentoutputType
- the specified output typecsvFileName
- the name of the output file to be added
-
-