@Override public void setMetadata(final Metadata meta) throws IOException { super.setMetadata(meta); if (reader != null) reader.close(); try { final String baseId = ZipUtilities.unzipId(locationService, meta.getSource(), null); reader = initializeService.initializeReader(baseId); meta.setMetadata(reader.getMetadata()); } catch (final FormatException e) { log().error("Failed to initialize delegate Reader", e); } }
@Override public void setSource(final RandomAccessInputStream stream, final SCIFIOConfig config) throws IOException { super.setSource(ZipUtilities.getRawStream(locationService, stream), config); if (reader != null) reader.close(); final String baseId = ZipUtilities.unzipId(locationService, stream, null); try { reader = formatService.getFormat(baseId, config).createReader(); reader.setSource(baseId, config); } catch (final FormatException e) { log().error("Failed to set delegate Reader's source", e); } }
@Override public void close(final boolean fileOnly) throws IOException { super.close(fileOnly); if (reader != null) reader.close(fileOnly); if (!fileOnly) reader = null; }