/* @see loci.formats.FormatReader#initFile(String) */ protected void initFile(String id) throws FormatException, IOException { super.initFile(id); reader = new ImageReader(); reader.setMetadataOptions(getMetadataOptions()); reader.setMetadataFiltered(isMetadataFiltered()); reader.setOriginalMetadataPopulated(isOriginalMetadataPopulated()); reader.setNormalized(isNormalized()); reader.setMetadataStore(getMetadataStore()); // NB: We need a raw handle on the ZIP data itself, not a ZipHandle. IRandomAccess rawHandle = Location.getHandle(id, false, false); in = new RandomAccessInputStream(rawHandle, id); ZipInputStream zip = new ZipInputStream(in); while (true) { ZipEntry ze = zip.getNextEntry(); if (ze == null) break; ZipHandle handle = new ZipHandle(id, ze); Location.mapFile(ze.getName(), handle); mappedFiles.add(ze.getName()); } ZipHandle base = new ZipHandle(id); reader.setId(base.getEntryName()); metadataStore = reader.getMetadataStore(); core = reader.getCoreMetadata(); metadata = reader.getGlobalMetadata(); base.close(); }
/** * Wrapper for bio-formats * * @param config - ImportConfit */ public OMEROWrapper(ImportConfig config) { if (config == null) { throw new IllegalArgumentException( "An ImportConfig must be instantitated \n " + "in order to properly configure all readers."); } this.config = config; try { String readersPath = config.readersPath.get(); // Since we now use all readers apart from the ZipReader, just // initialize in this manner which helps us by not requiring // us to keep up with all changes in readers.txt and removes // the requirement for importer_readers.txt (See #2859). // Chris Allan <*****@*****.**> -- Fri 10 Sep 2010 17:24:49 BST ClassList<IFormatReader> readers = ImageReader.getDefaultReaderClasses(); readers.removeClass(ZipReader.class); if (readersPath != null) { Class<?> k = getClass(); if (new File(readersPath).exists()) { k = null; } readers = new ClassList<IFormatReader>(readersPath, IFormatReader.class, k); } iReader = new ImageReader(readers); filler = new ChannelFiller(iReader); } catch (IOException e) { throw new RuntimeException("Unable to load readers.txt."); } reader = separator = new ChannelSeparator(filler); // Force unreadable characters to be removed from metadata key/value pairs iReader.setMetadataFiltered(true); filler.setMetadataFiltered(true); separator.setMetadataFiltered(true); };