## loci.formats
Class FormatReader

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

Direct Known Subclasses:
  AVIReader, BaseTiffReader, BioRadReader, BMPReader, DeltavisionReader, GatanReader, ICSReader, ImageIOReader, ImageJReader, ImageReader, IPLabReader, LegacyPictReader, LegacyQTReader, LegacyZVIReader, LeicaReader, OMEXMLReader, OpenlabReader, PerkinElmerReader, PictReader, QTReader, ZeissZVIReader

public abstract class FormatReader
extends FormatHandler

Abstract superclass of all biological file format readers.

Field Summary
`protected static boolean` `DEBUG` Debugging flag.
`protected static int` `DEBUG_LEVEL` Debugging level.
`protected Hashtable` `metadata` Hashtable containing metadata key/value pairs.
`protected Object` `ome` OME root node for OME-XML metadata.

Fields inherited from class loci.formats.FormatHandler
`chooser, currentId, filters, format, suffixes`

Constructor Summary
`FormatReader(String format, String suffix)` Constructs a format reader with the given name and default suffix.
`FormatReader(String format, String[] suffixes)` Constructs a format reader with the given name and default suffixes.

Method Summary
`abstract void` `close()` Closes the currently open file.
`protected void` `createFilters()` Creates JFileChooser file filters for this file format.
`abstract int` `getImageCount(String id)` Determines the number of images in the given file.
`Hashtable` `getMetadata(String id)` Obtains the hashtable containing the metadata field/value pairs from the given file.
`Object` `getMetadataValue(String id, String field)` Obtains the specified metadata field's value for the given file.
`Object` `getOMENode(String id)` Obtains a loci.ome.xml.OMENode object representing the file's metadata as an OME-XML DOM structure.
`protected void` `initFile(String id)` Initializes the given file (parsing header information, etc.).
`abstract boolean` `isThisType(byte[] block)` Checks if the given block is a valid header for this file format.
`BufferedImage[]` `open(String id)` Opens an existing file from the given filename.
`abstract BufferedImage` `open(String id, int no)` Obtains the specified image from the given file.
`boolean` `testRead(String[] args)` A utility method for test reading a file from the command line, and displaying the results in a simple display.

Methods inherited from class loci.formats.FormatHandler
`getFileChooser, getFileFilters, getFormat, getSuffixes, isThisType`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEBUG

    protected static final boolean DEBUG

  Debugging flag.

  See Also:
    Constant Field Values

### DEBUG_LEVEL

    protected static final int DEBUG_LEVEL

  Debugging level. 1=basic, 2=extended, 3=everything.

  See Also:
    Constant Field Values

### metadata

    protected Hashtable metadata

  Hashtable containing metadata key/value pairs.

### ome

    protected Object ome

  OME root node for OME-XML metadata.

Constructor Detail

### FormatReader

    public FormatReader(String format,
                        String suffix)

  Constructs a format reader with the given name and default suffix.

### FormatReader

    public FormatReader(String format,
                        String[] suffixes)

  Constructs a format reader with the given name and default suffixes.

Method Detail

### isThisType

    public abstract boolean isThisType(byte[] block)

  Checks if the given block is a valid header for this file format.

### getImageCount

    public abstract int getImageCount(String id)
                               throws FormatException,
                                      IOException

  Determines the number of images in the given file.

  Throws:
    `FormatException`
    `IOException`

### open

    public abstract BufferedImage open(String id,
                                       int no)
                                throws FormatException,
                                       IOException

  Obtains the specified image from the given file.

  Throws:
    `FormatException`
    `IOException`

### close

    public abstract void close()
                        throws FormatException,
                               IOException

  Closes the currently open file.

  Throws:
    `FormatException`
    `IOException`

### initFile

    protected void initFile(String id)
                     throws FormatException,
                            IOException

  Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.

  Throws:
    `FormatException`
    `IOException`

### open

    public BufferedImage[] open(String id)
                         throws FormatException,
                                IOException

  Opens an existing file from the given filename.

  Returns:
    Java Images containing pixel data
  Throws:
    `FormatException`
    `IOException`

### getOMENode

    public Object getOMENode(String id)
                      throws FormatException,
                             IOException

  Obtains a loci.ome.xml.OMENode object representing the file's metadata as an OME-XML DOM structure.

  Returns:
    null if the loci.ome.xml package is not present.
  Throws:
    `FormatException`
    `IOException`

### getMetadataValue

    public Object getMetadataValue(String id,
                                   String field)
                            throws FormatException,
                                   IOException

  Obtains the specified metadata field's value for the given file.

  Parameters:
    `field` - the name associated with the metadata field
  Returns:
    the value, or null if the field doesn't exist
  Throws:
    `FormatException`
    `IOException`

### getMetadata

    public Hashtable getMetadata(String id)
                          throws FormatException,
                                 IOException

  Obtains the hashtable containing the metadata field/value pairs from the given file.

  Parameters:
    `id` - the filename
  Returns:
    the hashtable containing all metadata from the file
  Throws:
    `FormatException`
    `IOException`

### testRead

    public boolean testRead(String[] args)
                     throws FormatException,
                            IOException

  A utility method for test reading a file from the command line, and displaying the results in a simple display.

  Throws:
    `FormatException`
    `IOException`

### createFilters

    protected void createFilters()

  Creates JFileChooser file filters for this file format.

  Overrides:
    `createFilters` in class `FormatHandler`