public class Results
extends Object
ResultFormatterSimple
for saving results and a
ResultFormatterDate
for printing results. These default formatters
can be changed via setPrintFormatter(ResultFormatter)
and
setSaveFormatter(ResultFormatter)
, respectively.
Example
ResultFormatterDate rfd = new ResultFormatterDate(); rfd.setTimebase(exec.getStart()); Results.setPrintFormatter(rfd);Additionally, a specific formatter can be used per-call, see the print/save/append methods.
Moreover, the class provides 2 utility methods that are useful if results shall be queried at a time, where the Execution and ResultHandle instances are not available any more.
The method marshallQuery(Execution, ResultHandle)
creates a String
that contains all the information which is needed to retrieve results for
(exec,handle) at a later time. From this String, a Query
instance can
be regenerated using unmarshallQuery(String)
.
Modifier and Type | Field and Description |
---|---|
static String |
SUFFIX_BIN |
static String |
SUFFIX_TXT |
Modifier and Type | Method and Description |
---|---|
static void |
append(List<Result> results,
java.io.File file)
Append all results to
file . |
static void |
append(List<Result> results,
java.io.File file,
ResultFormatter formatter)
Appends all results to
file . |
static void |
append(List<Result> results,
String filename)
Append all results to
filename . |
static void |
append(List<Result> results,
String filename,
ResultFormatter formatter)
Append all results to
filename . |
static void |
disableAutoSuffix() |
static void |
enableAutoSuffix() |
static void |
getAndPrint(Execution exec,
Collection<ResultHandle> handles)
For each result handle the results are incrementally loaded from the
MINER Core and printed to System.out.
|
static void |
getAndPrint(Execution exec,
ResultFormatter formatter,
Collection<ResultHandle> handles)
For each result handle the results are incrementally loaded from the
MINER Core and printed to System.out.
|
static void |
getAndPrint(Execution exec,
ResultFormatter formatter,
ResultHandle... handles)
For each result handle the results are incrementally loaded from the
MINER Core and printed to System.out.
|
static void |
getAndPrint(Execution exec,
ResultHandle... handles)
For each result handle the results are incrementally loaded from the
MINER Core and printed to System.out.
|
static void |
getAndPrintAllResults(Execution exec)
Gets the results and prints them to System.out for each ResultHandle
defined in the scenario of this execution.
|
static void |
getAndPrintAllResults(Execution exec,
ResultFormatter formatter)
Gets the results and prints them to System.out for each ResultHandle
defined in the scenario of this execution.
|
static List<Result> |
getAndPrintAndReturn(Execution exec,
ResultFormatter formatter,
ResultHandle handle)
Gets all results from the MINER Core, prints them and returns the
results.
|
static List<Result> |
getAndPrintAndReturn(Execution exec,
ResultHandle handle)
Gets all results from the MINER Core, prints them and returns the
results.
|
static void |
getAndSave(Execution exec,
Collection<ResultHandle> handles)
For each result handle the results are incrementally loaded from the
MINER Core and saved to a file.
|
static void |
getAndSave(Execution exec,
ResultFormatter formatter,
Collection<ResultHandle> handles)
For each result handle the results are incrementally loaded from the
MINER Core and saved to a file.
|
static void |
getAndSave(Execution exec,
ResultFormatter formatter,
ResultHandle... handles)
For each result handle the results are incrementally loaded from the
MINER Core and saved to a file.
|
static void |
getAndSave(Execution exec,
ResultHandle... handles)
For each result handle the results are incrementally loaded from the
MINER Core and saved to a file.
|
static void |
getAndSaveAllResults(Execution exec)
Incrementally gets the results and saves them for each ResultHandle
defined in the scenario of this execution.
|
static void |
getAndSaveAllResults(Execution exec,
ResultFormatter formatter)
Incrementally gets the results and saved them for each ResultHandle
defined in the scenario of this execution.
|
static List<Result> |
getAndSaveAndReturn(Execution exec,
ResultFormatter formatter,
ResultHandle handle)
Gets all results from the MINER Core, saves them and returns the results.
|
static List<Result> |
getAndSaveAndReturn(Execution exec,
ResultHandle handle)
Gets all results from the MINER Core, saves them and returns the results.
|
static ResultFormatter |
getPrintFormatter()
Gets the print formatter.
|
static java.io.File |
getResultFileAndCreateParentDirs(String filename)
Creates a File instance in one of the following directories (whatever
matches first):
the absolute or relative path defined in
filename if set
the getSaveDir() if set
the working directory
If necessary non-existent parent directories are created. |
static java.io.File |
getSaveDir()
Gets the base directory for saving results.
|
static ResultFormatter |
getSaveFormatter()
Gets the default ResultFormatter used for saving results.
|
static void |
marshallQueriesToFile(java.io.File file,
Execution exec,
Collection<ResultHandle> handles)
For each handle, a queryString is created via
marshallQuery(Execution, ResultHandle) and saved to
file . |
static void |
marshallQueriesToFile(java.io.File file,
Execution exec,
ResultHandle... handles)
For each handle, a queryString is created via
marshallQuery(Execution, ResultHandle) and saved to
file . |
static String |
marshallQuery(Execution exec,
ResultHandle handle)
Creates a String that contains all the information which is needed to
retrieve results for (exec,handle) at a later time.
|
static void |
print(List<Result> results)
Prints all results to System.out using the default result formatter.
|
static void |
print(List<Result> results,
ResultFormatter formatter)
Prints all results to System.out using the given formatter.
|
static void |
save(List<Result> results,
java.io.File file)
Saves all results to
file . |
static void |
save(List<Result> results,
java.io.File file,
ResultFormatter formatter)
Saves all results to
file . |
static void |
save(List<Result> results,
String filename)
Saves all results to
filename . |
static void |
save(List<Result> results,
String filename,
ResultFormatter formatter)
Saves all results to
filename . |
static void |
setPrintFormatter(ResultFormatter formatter)
Sets the default ResultFormatter used for printing results.
|
static void |
setSaveDir(java.io.File dir)
Sets the base directory for saving results.
|
static void |
setSaveFormatter(ResultFormatter formatter)
Sets the default ResultFormatter used for saving results.
|
static Map<Proxy,List<Result>> |
splitByProxy(List<Result> results) |
static Query |
unmarshallQuery(String savedQuery)
Creates a Query instance from a String which was previously generated
using
marshallQuery(Execution, ResultHandle, String) . |
public static final String SUFFIX_TXT
public static final String SUFFIX_BIN
public static void print(List<Result> results)
results
- the list of results to be printedpublic static void print(List<Result> results, ResultFormatter formatter)
results
- the result list to be printedformatter
- the formatter which transforms results to Stringpublic static void save(List<Result> results, String filename) throws java.io.IOException
filename
. The target directory is
either getSaveDir()
if it is set; otherwise it is the
working directory. The results are converted to String using the default
result formatter for saving files, see
setSaveFormatter(ResultFormatter)
.results
- the list of result instancesfilename
- the target file namejava.io.IOException
public static void save(List<Result> results, String filename, ResultFormatter formatter) throws java.io.IOException
filename
. The target directory is
either getSaveDir()
if it is set; otherwise it is the
working directory. The results are converted to String using
formatter
.results
- the list of result instancesfilename
- the target file nameformatter
- the formatter which transforms results to Stringjava.io.IOException
public static void save(List<Result> results, java.io.File file) throws java.io.IOException
file
. The file is overwritten if it
exists already. The results are converted to String using the default
result formatter for saving files, see
setSaveFormatter(ResultFormatter)
. Note that unlike
save(List, String)
this method ignores the
getSaveDir()
.results
- the list of result instancesfile
- the destination filejava.io.IOException
public static void save(List<Result> results, java.io.File file, ResultFormatter formatter) throws java.io.IOException
file
. The file is overwritten if it
exists already. The results are converted to String with the given
formatter. Note that unlike save(List, String, ResultFormatter)
this method ignores the getSaveDir()
.results
- the list of result instancesfile
- the destination fileformatter
- the formatter which transforms results to Stringjava.io.IOException
public static void append(List<Result> results, String filename) throws java.io.IOException
filename
. The target directory is
either getSaveDir()
if it is set; otherwise it is the
working directory. The file is created if it doesn't exist. The results
are converted to String using the default result formatter for saving
files, see setSaveFormatter(ResultFormatter)
.results
- the list of result instancesfilename
- the destination filenamejava.io.IOException
public static void append(List<Result> results, String filename, ResultFormatter formatter) throws java.io.IOException
filename
. The target directory is
either getSaveDir()
if it is set; otherwise it is the
working directory. The file is created if it doesn't exist. The results
are converted using formatter
.results
- the list of result instancesfilename
- the destination filenameformatter
- the result formatterjava.io.IOException
public static void append(List<Result> results, java.io.File file) throws java.io.IOException
file
. The file is created if it
doesn't exist. The results are converted to String using the default
result formatter for saving files, see
setSaveFormatter(ResultFormatter)
. Note that unlike
append(List, String)
this method ignores the
getSaveDir()
.results
- the list of result instancesfile
- the destination filejava.io.IOException
public static void append(List<Result> results, java.io.File file, ResultFormatter formatter) throws java.io.IOException
file
. The file is created if it
doesn't exist. The results are converted to String using the given
formatter
. Note that unlike
append(List, String, ResultFormatter)
this method ignores the
getSaveDir()
.results
- the list of result instancesfile
- the destination fileformatter
- the result formatterjava.io.IOException
public static void getAndPrintAllResults(Execution exec) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the default result formatter for printing results, see
setPrintFormatter(ResultFormatter)
.exec
- the executionat.srfg.miner.exception.MinerException
public static void getAndPrintAllResults(Execution exec, ResultFormatter formatter) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterat.srfg.miner.exception.MinerException
public static void getAndPrint(Execution exec, ResultHandle... handles) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the default result formatter for printing results, see
setPrintFormatter(ResultFormatter)
.exec
- the executionhandles
- the result handlesat.srfg.miner.exception.MinerException
public static void getAndPrint(Execution exec, Collection<ResultHandle> handles) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the default result formatter for printing results, see
setPrintFormatter(ResultFormatter)
.exec
- the executionhandles
- the result handlesat.srfg.miner.exception.MinerException
public static void getAndPrint(Execution exec, ResultFormatter formatter, ResultHandle... handles) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterhandles
- the result handlesat.srfg.miner.exception.MinerException
public static void getAndPrint(Execution exec, ResultFormatter formatter, Collection<ResultHandle> handles) throws at.srfg.miner.exception.MinerException
# resultName[-resultSelector]then follow the results and finally a newline is printed. The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterhandles
- the result handlesat.srfg.miner.exception.MinerException
public static List<Result> getAndPrintAndReturn(Execution exec, ResultHandle handle) throws at.srfg.miner.exception.MinerException
setPrintFormatter(ResultFormatter)
.exec
- the executionhandle
- the result handleat.srfg.miner.exception.MinerException
public static List<Result> getAndPrintAndReturn(Execution exec, ResultFormatter formatter, ResultHandle handle) throws at.srfg.miner.exception.MinerException
formatter
.exec
- the executionformatter
- the result formatterhandle
- the result handleat.srfg.miner.exception.MinerException
public static void getAndSaveAllResults(Execution exec) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the default result
formatter for saving files, see
setSaveFormatter(ResultFormatter)
.exec
- the executionjava.io.IOException
at.srfg.miner.exception.MinerException
public static void getAndSaveAllResults(Execution exec, ResultFormatter formatter) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterjava.io.IOException
at.srfg.miner.exception.MinerException
public static void getAndSave(Execution exec, ResultHandle... handles) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the default result
formatter for saving files, see
setSaveFormatter(ResultFormatter)
.exec
- the executionhandles
- the result handlesjava.io.IOException
at.srfg.miner.exception.MinerException
public static void getAndSave(Execution exec, ResultFormatter formatter, ResultHandle... handles) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterhandles
- the result handlesjava.io.IOException
at.srfg.miner.exception.MinerException
public static void getAndSave(Execution exec, Collection<ResultHandle> handles) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the default result
formatter for saving files, see
setSaveFormatter(ResultFormatter)
exec
- the executionhandles
- the result handlesjava.io.IOException
at.srfg.miner.exception.MinerException
public static void getAndSave(Execution exec, ResultFormatter formatter, Collection<ResultHandle> handles) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set. Otherwise, the filename is
created from properties of the result handle. If the target file already
exists it is deleted (and if it can't be deleted an IOException is
thrown). The results are converted to String using the given
formatter
.exec
- the executionformatter
- the result formatterhandles
- the result handlesjava.io.IOException
at.srfg.miner.exception.MinerException
public static List<Result> getAndSaveAndReturn(Execution exec, ResultHandle handle) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set.
Otherwise, the filename is created from properties of the result handle.
If the target file already exists it is deleted (and if it can't be
deleted an IOException is thrown). The results are converted to String
using the default result formatter for saving files, see
setSaveFormatter(ResultFormatter)
.exec
- the executionhandle
- the result handlejava.io.IOException
at.srfg.miner.exception.MinerException
public static List<Result> getAndSaveAndReturn(Execution exec, ResultFormatter formatter, ResultHandle handle) throws java.io.IOException, at.srfg.miner.exception.MinerException
ResultHandle.getSavePattern()
if set.
Otherwise, the filename is created from properties of the result handle.
If the target file already exists it is deleted (and if it can't be
deleted an IOException is thrown). The results are converted to String
using the given formatter
.exec
- the executionformatter
- the result formatterhandle
- the result handlejava.io.IOException
at.srfg.miner.exception.MinerException
public static void enableAutoSuffix()
public static void disableAutoSuffix()
public static ResultFormatter getPrintFormatter()
public static void setPrintFormatter(ResultFormatter formatter)
formatter
- the formatterpublic static ResultFormatter getSaveFormatter()
public static void setSaveFormatter(ResultFormatter formatter)
formatter
- the formatterpublic static String marshallQuery(Execution exec, ResultHandle handle)
Query
instance can be generated at a later time using
unmarshallQuery(String)
.exec
- the executionhandle
- the result handlepublic static void marshallQueriesToFile(java.io.File file, Execution exec, ResultHandle... handles) throws java.io.IOException
marshallQuery(Execution, ResultHandle)
and saved to
file
.file
- the output fileexec
- the executionhandles
- the result handlesjava.io.IOException
public static void marshallQueriesToFile(java.io.File file, Execution exec, Collection<ResultHandle> handles) throws java.io.IOException
marshallQuery(Execution, ResultHandle)
and saved to
file
.file
- the output fileexec
- the executionhandles
- the result handlesjava.io.IOException
public static Query unmarshallQuery(String savedQuery)
marshallQuery(Execution, ResultHandle, String)
.savedQuery
- the query stringpublic static java.io.File getResultFileAndCreateParentDirs(String filename)
filename
if set
getSaveDir()
if setfilename
- the filename which may contain an absolute or relative path
specificationpublic static void setSaveDir(java.io.File dir) throws java.io.IOException, IllegalArgumentException
dir
- the saveDir to setIllegalArgumentException
- if saveDir
is not an existing directory with
write permissions.java.io.IOException
public static java.io.File getSaveDir()
Copyright (c) Salzburg Research Forschungsgesellschaft mbH. All rights reserved.