Package org.goplanit.output.formatter
Class BaseOutputFormatter
- java.lang.Object
-
- org.goplanit.output.formatter.BaseOutputFormatter
-
- All Implemented Interfaces:
OutputFormatter
- Direct Known Subclasses:
FileOutputFormatter,MemoryOutputFormatter
public abstract class BaseOutputFormatter extends Object implements OutputFormatter
Base class for all formatters of output data, i.e. persistence of certain types of data into a particular format- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected longidUnique internal id of the output writerprotected StringinitialCostsLocationThe location of the initial costs filesprotected Map<OutputType,OutputProperty[]>outputKeyPropertiesMap of OutputProperties of keys for each OutputTypeprotected UnitoutputTimeUnitTime unit to be used in outputsprotected Map<OutputType,Boolean>outputTypeKeysLockedMap to store which output types are already in use as keysprotected Set<OutputType>outputTypesList of registered OutputTypesprotected Map<OutputType,Boolean>outputTypeValuesLockedMap to store whether any data values have been stored for a given output type.protected Map<OutputType,OutputProperty[]>outputValuePropertiesMap of OutputProperties for values for each OutputType-
Fields inherited from interface org.goplanit.output.formatter.OutputFormatter
MEMORY_OUTPUT_FORMATTER, NOT_SPECIFIED, PLANIT_OUTPUT_FORMATTER
-
-
Constructor Summary
Constructors Constructor Description BaseOutputFormatter(IdGroupingToken groupId)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longgetId()Collect the id of the formatterprotected voidlockOutputProperties(OutputType outputType)Lock the output keys and values for a specified output typevoidpersist(TimePeriod timePeriod, Set<Mode> modes, OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputAdapter outputAdapter)Write data to output fileprotected abstract voidwriteGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)Write General results for the current time period to the CSV fileprotected abstract voidwriteLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)Write link results for the current time period to the CSV fileprotected abstract voidwriteOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)Write Origin-Destination results for the time period to the CSV fileprotected abstract voidwritePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)Write OD Path results for the time period to the CSV fileprotected abstract voidwriteSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)Write Simulation results for the current time period to the CSV file-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.output.formatter.OutputFormatter
canHandleMultipleIterations, finaliseAfterSimulation, initialiseBeforeSimulation
-
-
-
-
Field Detail
-
outputKeyProperties
protected Map<OutputType,OutputProperty[]> outputKeyProperties
Map of OutputProperties of keys for each OutputType
-
outputValueProperties
protected Map<OutputType,OutputProperty[]> outputValueProperties
Map of OutputProperties for values for each OutputType
-
outputTypeValuesLocked
protected Map<OutputType,Boolean> outputTypeValuesLocked
Map to store whether any data values have been stored for a given output type. If data have been stored for an output type, it is "locked" so its key and output properties cannot be reset
-
outputTypeKeysLocked
protected Map<OutputType,Boolean> outputTypeKeysLocked
Map to store which output types are already in use as keys
-
id
protected long id
Unique internal id of the output writer
-
outputTimeUnit
protected Unit outputTimeUnit
Time unit to be used in outputs
-
outputTypes
protected Set<OutputType> outputTypes
List of registered OutputTypes
-
initialCostsLocation
protected String initialCostsLocation
The location of the initial costs files
-
-
Constructor Detail
-
BaseOutputFormatter
public BaseOutputFormatter(IdGroupingToken groupId)
Constructor- Parameters:
groupId- , contiguous id generation within this group for instances of this class
-
-
Method Detail
-
lockOutputProperties
protected void lockOutputProperties(OutputType outputType)
Lock the output keys and values for a specified output type- Parameters:
outputType- the output type to be locked
-
writeLinkResultsForCurrentTimePeriod
protected abstract void writeLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write link results for the current time period to the CSV file- Parameters:
outputConfiguration- output configurationoutputTypeConfiguration- OutputTypeConfiguration for current persistencecurrentOutputType- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter- OutputAdapter for current persistencemodes- Set of modes of traveltimePeriod- current time perioditerationIndex- current iteration index- Throws:
PlanItException- thrown if there is an error
-
writeGeneralResultsForCurrentTimePeriod
protected abstract void writeGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write General results for the current time period to the CSV file- Parameters:
outputConfiguration- output configurationoutputTypeConfiguration- OutputTypeConfiguration for current persistencecurrentOutputType- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter- OutputAdapter for current persistencemodes- Set of modes of traveltimePeriod- current time perioditerationIndex- current iteration index- Throws:
PlanItException- thrown if there is an error
-
writeOdResultsForCurrentTimePeriod
protected abstract void writeOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Origin-Destination results for the time period to the CSV file- Parameters:
outputConfiguration- output configurationoutputTypeConfiguration- OutputTypeConfiguration for current persistencecurrentOutputType- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter- OutputAdapter for current persistencemodes- Set of modes of traveltimePeriod- current time perioditerationIndex- current iteration index- Throws:
PlanItException- thrown if there is an error
-
writeSimulationResultsForCurrentTimePeriod
protected abstract void writeSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Simulation results for the current time period to the CSV file- Parameters:
outputConfiguration- output configurationoutputTypeConfiguration- OutputTypeConfiguration for current persistencecurrentOutputType- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter- OutputAdapter for current persistencemodes- Set of modes of traveltimePeriod- current time perioditerationIndex- current iteration index- Throws:
PlanItException- thrown if there is an error
-
writePathResultsForCurrentTimePeriod
protected abstract void writePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write OD Path results for the time period to the CSV file- Parameters:
outputConfiguration- output configurationoutputTypeConfiguration- OutputTypeConfiguration for current persistencecurrentOutputType- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter- OutputAdapter for current persistencemodes- Set of modes of traveltimePeriod- current time perioditerationIndex- current iteration index- Throws:
PlanItException- thrown if there is an error
-
persist
public void persist(TimePeriod timePeriod, Set<Mode> modes, OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputAdapter outputAdapter) throws PlanItException
Write data to output file- Specified by:
persistin interfaceOutputFormatter- Parameters:
timePeriod- time period for current resultsmodes- Set of modes covered by current resultsoutputConfiguration- output configurationoutputTypeConfiguration- output configuration being usedoutputAdapter- output adapter being used- Throws:
PlanItException- thrown if there is an error
-
getId
public long getId()
Description copied from interface:OutputFormatterCollect the id of the formatter- Specified by:
getIdin interfaceOutputFormatter- Returns:
- id
-
-