示例#1
0
  /* @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();
  }
示例#2
0
 /**
  * Checks that the given id points at a valid data stream.
  *
  * @param id The id string to validate.
  * @throws IOException if the id is not valid.
  */
 public static void checkValidId(String id) throws IOException {
   if (getMappedFile(id) != null) {
     // NB: The id maps directly to an IRandomAccess handle, so is valid. Do
     // not destroy an existing mapped IRandomAccess handle by closing it.
     return;
   }
   // NB: Try to actually open a handle to make sure it is valid. Close it
   // afterward so we don't leave it dangling. The process of doing this will
   // throw IOException if something goes wrong.
   Location.getHandle(id).close();
 }
 private static IRandomAccess getHandle(String file) throws IOException {
   return Location.getHandle(file, false, false);
 }