Skip to content
Snippets Groups Projects
Commit 84e9c0d3 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Dispose SCIFIO context.

parent 6e084735
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ import org.apache.commons.cli.*;
import java.io.IOException;
public class DataCompressor {
public static void main(String[] args) {
Options options = CliConstants.getOptions();
......@@ -30,8 +31,10 @@ public class DataCompressor {
}
ParsedCliOptions parsedCliOptions = new ParsedCliOptions(cmd);
if (parsedCliOptions.didErrorOccure()) {
// NOTE(Moravec): From this point we need to dispose of possible existing SCIFIO context.
if (parsedCliOptions.failedToParse()) {
System.err.println(parsedCliOptions.getError());
ScifioWrapper.dispose();
return;
}
......@@ -46,26 +49,27 @@ public class DataCompressor {
if (!compressor.compress()) {
System.err.println("Errors occurred during compression.");
}
return;
}
break;
case Decompress: {
ImageDecompressor decompressor = new ImageDecompressor(parsedCliOptions);
if (!decompressor.decompress()) {
System.err.println("Errors occurred during decompression.");
}
return;
}
break;
case Benchmark: {
CompressionBenchmark.runBenchmark(parsedCliOptions);
return;
}
break;
case TrainCodebook: {
ImageCompressor compressor = new ImageCompressor(parsedCliOptions);
if (!compressor.trainAndSaveCodebook()) {
System.err.println("Errors occurred during training/saving of codebook.");
}
return;
}
break;
case CustomFunction: {
// NOTE(Moravec): Custom function class here |
// V
......@@ -73,9 +77,8 @@ public class DataCompressor {
if (!customFunction.run()) {
System.err.println("Errors occurred during custom function.");
}
return;
}
break;
case PrintHelp: {
formatter.printHelp(CliConstants.MAIN_HELP, options);
......@@ -90,9 +93,9 @@ public class DataCompressor {
System.err.println(e.getMessage());
e.printStackTrace();
}
return;
}
break;
}
return;
ScifioWrapper.dispose();
}
}
......@@ -182,7 +182,7 @@ public class ParsedCliOptions {
// inputFileInfo is already created with TIFF type.
assert (inputFileInfo.getFileType() == FileType.TIFF) : "Not TIFF type in parse Tiff arguments.";
errorOccurred = true;
errorBuilder.append("Got TIFF file.\n");
......@@ -455,7 +455,7 @@ public class ParsedCliOptions {
return refPlaneIndexSet;
}
public boolean didErrorOccure() {
public boolean failedToParse() {
return errorOccurred;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment