Package org.moeaframework.analysis.io
Class ResultWriter
java.lang.Object
org.moeaframework.analysis.io.ResultWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
MetricFileWriter
,ResultFileWriter
Abstract class for result writers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
failIfOutdated
(CommandLineUtility cli, File input, File output) Checks the last modified timestamp of the input and output files, throwing if the input is newer than the output.abstract int
Returns the number of entries in the file.static boolean
Replaces the destination file with the source file, but only if content is different.abstract void
write
(ResultEntry entry) Writes the specified non-dominated population and optional attributes to the file.
-
Constructor Details
-
ResultWriter
public ResultWriter()Constructs a new result writer.
-
-
Method Details
-
getNumberOfEntries
public abstract int getNumberOfEntries()Returns the number of entries in the file. If the file already existed, this returns the number of complete entries in the output file. This value is incremented on every invocation to thewrite(org.moeaframework.analysis.series.ResultEntry)
method.- Returns:
- the number of entries in the file
-
write
Writes the specified non-dominated population and optional attributes to the file.- Parameters:
entry
- the non-dominated population and optional attributes- Throws:
IOException
- if an I/O error occurred
-
replace
Replaces the destination file with the source file, but only if content is different. This avoids changing the modification timestamp on the file if the files are identical.- Parameters:
source
- the source file, which is required to existdestination
- the destination file, which might not exist- Returns:
true
if the destination was updated;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
failIfOutdated
Checks the last modified timestamp of the input and output files, throwing if the input is newer than the output. This check should be performed before appending to existing files.- Parameters:
cli
- the command line utilityinput
- the input fileoutput
- the output file
-