CSV_FILE_EXTENSION);
return new FileWithExtension(
csvFileForViewing, CSV_FILE_EXTENSION);
} catch (FileCopyingException csvFileCopyingException) {
throw new ConvertDataForViewingException(
csvFileCopyingException);
}
} else if (dataIsCSVCompatible(data, converterManager)) {
/*
* The data is either a CSV file already or CSV-convertible.
* This needs to be handled specially so data that can be
* viewed in Excel gets viewed in Excel.
*/
File preparedFileForViewing = prepareFileForViewing(
data, CSV_FILE_EXTENSION, converterManager);
return new FileWithExtension(preparedFileForViewing, CSV_FILE_EXTENSION);
} else if (dataIsFile(data, dataFormat)) {
/*
* The data is already a text-based file, so it just needs to
* be copied to a temporary file for viewing in the default
* text-viewing program.
*/
return new FileWithExtension(prepareTextFileForViewing(data), TXT_FILE_EXTENSION);
} else if (convertersExist(
data, ANY_FILE_EXTENSION_FILTER, converterManager)) {
/*
* The data is an another type, but it can be converted to a
* text-based file type for viewing in the default
* text-viewing program.
*/
return new FileWithExtension(
convertDataToTextFile(data, converterManager, ciShellContext),
"txt");
} else {
String exceptionMessage = String.format(
"No converters exist for the data \"%s\".",
data.getMetadata().get(DataProperty.LABEL));
throw new ConvertDataForViewingException(exceptionMessage);
}
} catch (ConvertDataForViewingException e) {
String exceptionMessage = String.format(
"There was a problem when preparing the data \"%s\" for viewing.",
data.getMetadata().get(DataProperty.LABEL));