* - Avalon format
* - CSV format
*
*/
public void loadExistingFile() {
final Visualizer visualizer = getVisualizer();
if (visualizer == null) {
return; // No point reading the file if there's no visualiser
}
boolean parsedOK = false, errorDetected = false;
String filename = getFilename();
File file = new File(filename);
if (file.exists()) {
clearVisualizer();
BufferedReader dataReader = null;
BufferedInputStream bufferedInputStream = null;
try {
dataReader = new BufferedReader(new FileReader(file));
// Get the first line, and see if it is XML
String line = dataReader.readLine();
if (line == null) {
log.warn(filename+" is empty");
} else {
if (!line.startsWith("<?xml ")){// No, must be CSV //$NON-NLS-1$
long lineNumber=1;
SampleSaveConfiguration saveConfig = CSVSaveService.getSampleSaveConfiguration(line,filename);
if (saveConfig == null) {// not a valid header
saveConfig = (SampleSaveConfiguration) getSaveConfig().clone(); // CSVSaveService may change the format
} else { // header line has been processed, so read the next
line = dataReader.readLine();
lineNumber++;
}
while (line != null) { // Already read 1st line
SampleEvent event = CSVSaveService.makeResultFromDelimitedString(line,saveConfig,lineNumber);
if (event != null){
final SampleResult result = event.getResult();
if (isSampleWanted(result.isSuccessful())) {
visualizer.add(result);
}
}
line = dataReader.readLine();
lineNumber++;
}