It looks a good idea to allow creation TiffParser/TiffSaver classes without SCIFIO context, when it is not really necessary - as well as (probably) some other classes, working with SCIFIO files. For example, if we just need to parse IFDs and do something with data at the stored offsets, why must we use Context class? Parsing TIFF is relatively easy and "lightweight" task.
However, in current SCIFIO version we need SCIFIO context even for creating DataHandle on the base of some file:
context.getService(DataHandleService.class).create(location)
Of course, if works... but I must initialize all SCIFIO subsystem and think about freeing context.
Could you provide some method, for example, inside FileLocation class, which will create necessary DataHandle without Context? I'vecreated as little method as a workaround:
@SuppressWarnings("rawtypes, unchecked")
static DataHandle<Location> getDataHandle(Context context, Location location) {
Objects.requireNonNull(location, "Null location");
DataHandle<Location> dataHandle;
if (location instanceof FileLocation fileLocation) {
@SuppressWarnings("resource")
FileHandle fileHandle = new FileHandle();
fileHandle.set(fileLocation);
dataHandle = (DataHandle) fileHandle;
} else {
Objects.requireNonNull(context, "Null context is not allowed for non-file location: " + location);
dataHandle = context.getService(DataHandleService.class).create(location);
}
return dataHandle;
}
But it seems terribly and requires suppression of warnings.
It looks a good idea to allow creation TiffParser/TiffSaver classes without SCIFIO context, when it is not really necessary - as well as (probably) some other classes, working with SCIFIO files. For example, if we just need to parse IFDs and do something with data at the stored offsets, why must we use Context class? Parsing TIFF is relatively easy and "lightweight" task.
However, in current SCIFIO version we need SCIFIO context even for creating DataHandle on the base of some file:
context.getService(DataHandleService.class).create(location)Of course, if works... but I must initialize all SCIFIO subsystem and think about freeing context.
Could you provide some method, for example, inside FileLocation class, which will create necessary DataHandle without Context? I'vecreated as little method as a workaround:
But it seems terribly and requires suppression of warnings.