loci.formats

## Class DelegateReader

- java.lang.Object
- - loci.formats.FormatHandler
  - - loci.formats.FormatReader
    - - loci.formats.DelegateReader

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler
  Direct Known Subclasses:
    JPEGReader, TiffDelegateReader

      public abstract class DelegateReader
      extends FormatReader

  DelegateReader is a file format reader that selects which reader to use for a format if there are two readers which handle the same format.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IFormatReader` | `legacyReader` Legacy reader.
    `protected boolean` | `legacyReaderInitialized` Flag indicating that the legacy reader was successfully initialized.
    `protected IFormatReader` | `nativeReader` Native reader.
    `protected boolean` | `nativeReaderInitialized` Flag indicating that the native reader was successfully initialized.
    `protected boolean` | `useLegacy` Flag indicating whether to use legacy reader by default.

    - ### Fields inherited from class loci.formats.FormatReader

      `core, coreIndex, datasetDescription, domains, fillColor, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSION`

    - ### Fields inherited from class loci.formats.FormatHandler

      `COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes`

    - ### Fields inherited from interface loci.formats.IFormatReader

      `CAN_GROUP, CANNOT_GROUP, MUST_GROUP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DelegateReader(java.lang.String format, java.lang.String suffix)` Constructs a new delegate reader.
    `DelegateReader(java.lang.String format, java.lang.String[] suffixes)` Constructs a new delegate reader.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private boolean` | `callLegacyReader()`
    `void` | `close(boolean fileOnly)` Closes the currently open file.
    `short[][]` | `get16BitLookupTable()` Gets the 16-bit color lookup table associated with the most recently opened image.
    `byte[][]` | `get8BitLookupTable()` Gets the 8-bit color lookup table associated with the most recently opened image.
    `MetadataOptions` | `getMetadataOptions()`
    `int` | `getOptimalTileHeight()` Returns the optimal sub-image height for use with openBytes.
    `int` | `getOptimalTileWidth()` Returns the optimal sub-image width for use with openBytes.
    `java.lang.String[]` | `getSeriesUsedFiles(boolean noPixels)` Returns an array of filenames needed to open the current series.
    `java.util.Set<MetadataLevel>` | `getSupportedMetadataLevels()`
    `boolean` | `isLegacy()` Gets whether to use the legacy reader by default.
    `boolean` | `isThisType(loci.common.RandomAccessInputStream stream)` Checks if the given stream is a valid stream for this file format.
    `boolean` | `isThisType(java.lang.String name, boolean open)` Checks if a file matches the type of this format reader.
    `byte[]` | `openBytes(int no, byte[] buf, int x, int y, int w, int h)` Obtains a sub-image of the specified image plane into a pre-allocated byte array.
    `void` | `reopenFile()` Reopen any files that were closed, and which are expected to be open while the reader is open.
    `void` | `setCoreIndex(int no)` Set the current resolution/series (ignores subresolutions).
    `void` | `setFlattenedResolutions(boolean flattened)` Set whether or not to flatten resolutions into individual series.
    `void` | `setGroupFiles(boolean group)` Specifies whether or not to force grouping in multi-file formats.
    `void` | `setId(java.lang.String id)` Initialize a reader from the input file name.
    `void` | `setLegacy(boolean legacy)` Sets whether to use the legacy reader by default.
    `void` | `setMetadataFiltered(boolean filter)` Specifies whether ugly metadata (entries with unprintable characters, and extremely large entries) should be discarded from the metadata table.
    `void` | `setMetadataOptions(MetadataOptions options)`
    `void` | `setMetadataStore(MetadataStore store)` Sets the default metadata store for this reader.
    `void` | `setNormalized(boolean normalize)` Specifies whether or not to normalize float data.
    `void` | `setOriginalMetadataPopulated(boolean populate)` Specifies whether or not to save proprietary metadata in the MetadataStore.
    `void` | `setResolution(int resolution)` Set the resolution level.
    `void` | `setSeries(int no)` Activates the specified series.

    - ### Methods inherited from class loci.formats.FormatReader

      `addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMetaList, addMeta, addMetaList, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMetaList, close, coreIndexToSeries, fileGroupOption, flattenHashtables, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getAvailableOptions, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCoreIndex, getCoreMetadataList, getCorrection, getCurrentCore, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getDomains, getEffectiveSizeC, getExperimentType, getFilamentType, getFillColor, getFillRule, getFilterType, getFontFamily, getFontStyle, getGlobalMeta, getGlobalMetadata, getIlluminationType, getImageCount, getImmersion, getIndex, getIndex, getLaserMedium, getLaserType, getMarker, getMedium, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getMicrobeamManipulationType, getMicroscopeType, getModuloC, getModuloT, getModuloZ, getNamingConvention, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getResolution, getResolutionCount, getRGBChannelCount, getRotationTransform, getSeries, getSeriesCount, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getThumbSizeX, getThumbSizeY, getTileColumns, getTileRows, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, initFile, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openPlane, openThumbBytes, readPlane, readPlane, readPlane, seriesToCoreIndex, setFillColor, updateMetadataLists`

    - ### Methods inherited from class loci.formats.FormatHandler

      `checkSuffix, checkSuffix, getFormat, getNativeDataType, getSuffixes`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface loci.formats.IFormatHandler

      `getFormat, getNativeDataType, getSuffixes`

    - ### Methods inherited from interface loci.formats.ICompressedTileReader

      `getTileCodec, getTileCodecOptions, openCompressedBytes, openCompressedBytes`

- - ### Field Detail

    - #### useLegacy

          protected boolean useLegacy

      Flag indicating whether to use legacy reader by default.

    - #### nativeReader

          protected IFormatReader nativeReader

      Native reader.

    - #### legacyReader

          protected IFormatReader legacyReader

      Legacy reader.

    - #### nativeReaderInitialized

          protected boolean nativeReaderInitialized

      Flag indicating that the native reader was successfully initialized.

    - #### legacyReaderInitialized

          protected boolean legacyReaderInitialized

      Flag indicating that the legacy reader was successfully initialized.

  - ### Constructor Detail

    - #### DelegateReader

          public DelegateReader(java.lang.String format,
                                java.lang.String suffix)

      Constructs a new delegate reader.

    - #### DelegateReader

          public DelegateReader(java.lang.String format,
                                java.lang.String[] suffixes)

      Constructs a new delegate reader.

  - ### Method Detail

    - #### setLegacy

          public void setLegacy(boolean legacy)

      Sets whether to use the legacy reader by default.

    - #### isLegacy

          public boolean isLegacy()

      Gets whether to use the legacy reader by default.

    - #### getSupportedMetadataLevels

          public java.util.Set<MetadataLevel> getSupportedMetadataLevels()

      Specified by:
        `getSupportedMetadataLevels` in interface `IMetadataConfigurable`
      Overrides:
        `getSupportedMetadataLevels` in class `FormatHandler`

    - #### getMetadataOptions

          public MetadataOptions getMetadataOptions()

      Specified by:
        `getMetadataOptions` in interface `IMetadataConfigurable`
      Overrides:
        `getMetadataOptions` in class `FormatHandler`

    - #### setMetadataOptions

          public void setMetadataOptions(MetadataOptions options)

      Specified by:
        `setMetadataOptions` in interface `IMetadataConfigurable`
      Overrides:
        `setMetadataOptions` in class `FormatHandler`

    - #### isThisType

          public boolean isThisType(java.lang.String name,
                                    boolean open)

      Description copied from class: `FormatReader`
      Checks if a file matches the type of this format reader. Checks filename suffixes against those known for this format. If the suffix check is inconclusive and the open parameter is true, the file is opened and tested with `FormatReader.isThisType(RandomAccessInputStream)`.
      Specified by:
        `isThisType` in interface `IFormatReader`
      Overrides:
        `isThisType` in class `FormatReader`
        `open` - If true, and the file extension is insufficient to determine the file type, the (existing) file is opened for further analysis.

    - #### isThisType

          public boolean isThisType(loci.common.RandomAccessInputStream stream)
                             throws java.io.IOException

      Description copied from interface: `IFormatReader`
      Checks if the given stream is a valid stream for this file format. The number of bytes read is format-dependent.
      Specified by:
        `isThisType` in interface `IFormatReader`
      Overrides:
        `isThisType` in class `FormatReader`
      Parameters:
        `stream` - A RandomAccessInputStream representing the file to check. The first byte in the stream is assumed to be the first byte in the file.
      Returns:
        true if the file represented by the stream can be read by this reader; false otherwise.
      Throws:
        `java.io.IOException`

    - #### setSeries

          public void setSeries(int no)

      Description copied from interface: `IFormatReader`
      Activates the specified series. This also resets the resolution to 0.
      Specified by:
        `setSeries` in interface `IFormatReader`
      Overrides:
        `setSeries` in class `FormatReader`

    - #### setCoreIndex

          public void setCoreIndex(int no)

      Description copied from interface: `IFormatReader`
      Set the current resolution/series (ignores subresolutions). Equivalent to setSeries, but with flattened resolutions always set to false.
      Specified by:
        `setCoreIndex` in interface `IFormatReader`
      Overrides:
        `setCoreIndex` in class `FormatReader`

    - #### setResolution

          public void setResolution(int resolution)

      Description copied from interface: `IPyramidHandler`
      Set the resolution level.
      Specified by:
        `setResolution` in interface `IPyramidHandler`
      Overrides:
        `setResolution` in class `FormatReader`
      See Also:
        `IPyramidHandler.getResolutionCount()`

    - #### setNormalized

          public void setNormalized(boolean normalize)

      Description copied from interface: `IFormatReader`
      Specifies whether or not to normalize float data.
      Specified by:
        `setNormalized` in interface `IFormatReader`
      Overrides:
        `setNormalized` in class `FormatReader`

    - #### setOriginalMetadataPopulated

          public void setOriginalMetadataPopulated(boolean populate)

      Description copied from interface: `IFormatReader`
      Specifies whether or not to save proprietary metadata in the MetadataStore.
      Specified by:
        `setOriginalMetadataPopulated` in interface `IFormatReader`
      Overrides:
        `setOriginalMetadataPopulated` in class `FormatReader`

    - #### setGroupFiles

          public void setGroupFiles(boolean group)

      Description copied from interface: `IFormatReader`
      Specifies whether or not to force grouping in multi-file formats.
      Specified by:
        `setGroupFiles` in interface `IFormatReader`
      Overrides:
        `setGroupFiles` in class `FormatReader`
      See Also:
        `IFormatReader.fileGroupOption(String)`, `IFormatReader.isGroupFiles()`

    - #### setFlattenedResolutions

          public void setFlattenedResolutions(boolean flattened)

      Description copied from interface: `IFormatReader`
      Set whether or not to flatten resolutions into individual series.
      Specified by:
        `setFlattenedResolutions` in interface `IFormatReader`
      Overrides:
        `setFlattenedResolutions` in class `FormatReader`

    - #### setMetadataFiltered

          public void setMetadataFiltered(boolean filter)

      Description copied from interface: `IFormatReader`
      Specifies whether ugly metadata (entries with unprintable characters, and extremely large entries) should be discarded from the metadata table.
      Specified by:
        `setMetadataFiltered` in interface `IFormatReader`
      Overrides:
        `setMetadataFiltered` in class `FormatReader`

    - #### setMetadataStore

          public void setMetadataStore(MetadataStore store)

      Description copied from interface: `IFormatReader`
      Sets the default metadata store for this reader.
      Specified by:
        `setMetadataStore` in interface `IFormatReader`
      Overrides:
        `setMetadataStore` in class `FormatReader`
      Parameters:
        `store` - a metadata store implementation.

    - #### get8BitLookupTable

          public byte[][] get8BitLookupTable()
                                      throws FormatException,
                                             java.io.IOException

      Description copied from interface: `IFormatReader`
      Gets the 8-bit color lookup table associated with the most recently opened image. If no image planes have been opened, or if `IFormatReader.isIndexed()` returns false, then this may return null. Also, if `IFormatReader.getPixelType()` returns anything other than `FormatTools.INT8` or `FormatTools.UINT8`, this method will return null.
      Specified by:
        `get8BitLookupTable` in interface `IFormatReader`
      Overrides:
        `get8BitLookupTable` in class `FormatReader`
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### get16BitLookupTable

          public short[][] get16BitLookupTable()
                                        throws FormatException,
                                               java.io.IOException

      Description copied from interface: `IFormatReader`
      Gets the 16-bit color lookup table associated with the most recently opened image. If no image planes have been opened, or if `IFormatReader.isIndexed()` returns false, then this may return null. Also, if `IFormatReader.getPixelType()` returns anything other than `FormatTools.INT16` or `FormatTools.UINT16`, this method will return null.
      Specified by:
        `get16BitLookupTable` in interface `IFormatReader`
      Overrides:
        `get16BitLookupTable` in class `FormatReader`
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### getSeriesUsedFiles

          public java.lang.String[] getSeriesUsedFiles(boolean noPixels)

      Description copied from interface: `IFormatReader`
      Returns an array of filenames needed to open the current series. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed to `IFormatHandler.setId(String)`, if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.
      Specified by:
        `getSeriesUsedFiles` in interface `IFormatReader`
      Overrides:
        `getSeriesUsedFiles` in class `FormatReader`

    - #### openBytes

          public byte[] openBytes(int no,
                                  byte[] buf,
                                  int x,
                                  int y,
                                  int w,
                                  int h)
                           throws FormatException,
                                  java.io.IOException

      Description copied from interface: `IFormatReader`
      Obtains a sub-image of the specified image plane into a pre-allocated byte array.
      Specified by:
        `openBytes` in interface `IFormatReader`
      Specified by:
        `openBytes` in class `FormatReader`
      Parameters:
        `no` - the plane index within the current series.
        `buf` - a pre-allocated buffer.
        `x` - X coordinate of the upper-left corner of the sub-image
        `y` - Y coordinate of the upper-left corner of the sub-image
        `w` - width of the sub-image
        `h` - height of the sub-image
      Returns:
        the pre-allocated buffer `buf` for convenience.
      Throws:
        `FormatException` - if there was a problem parsing the metadata of the file.
        `java.io.IOException` - if there was a problem reading the file.

    - #### close

          public void close(boolean fileOnly)
                     throws java.io.IOException

      Description copied from interface: `IFormatReader`
      Closes the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to calling `Closeable.close()`.
      Specified by:
        `close` in interface `IFormatReader`
      Overrides:
        `close` in class `FormatReader`
      Throws:
        `java.io.IOException`

    - #### getOptimalTileWidth

          public int getOptimalTileWidth()

      Description copied from interface: `IFormatReader`
      Returns the optimal sub-image width for use with openBytes.
      Specified by:
        `getOptimalTileWidth` in interface `IFormatReader`
      Overrides:
        `getOptimalTileWidth` in class `FormatReader`

    - #### getOptimalTileHeight

          public int getOptimalTileHeight()

      Description copied from interface: `IFormatReader`
      Returns the optimal sub-image height for use with openBytes.
      Specified by:
        `getOptimalTileHeight` in interface `IFormatReader`
      Overrides:
        `getOptimalTileHeight` in class `FormatReader`

    - #### reopenFile

          public void reopenFile()
                          throws java.io.IOException

      Description copied from interface: `IFormatReader`
      Reopen any files that were closed, and which are expected to be open while the reader is open. This assumes that `IFormatHandler.setId(java.lang.String)` has been called, but close(false) has not been called.
      Specified by:
        `reopenFile` in interface `IFormatReader`
      Overrides:
        `reopenFile` in class `FormatReader`
      Throws:
        `java.io.IOException`

    - #### setId

          public void setId(java.lang.String id)
                     throws FormatException,
                            java.io.IOException

      Description copied from class: `FormatReader`
      Initialize a reader from the input file name. Call `FormatReader.initFile(String id)` to initialize the input file, read all of the metadata and set the reader up for reading planes. The performance of this method depends on the format and can be up to several minutes for large file sets.
      Specified by:
        `setId` in interface `IFormatHandler`
      Overrides:
        `setId` in class `FormatReader`
      Parameters:
        `id` - a `String` specifying the path to the file
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### callLegacyReader

          private boolean callLegacyReader()

Copyright © 2026 Open Microscopy Environment