loci.formats
Class FormatHandler

java.lang.Object
  extended by loci.formats.FormatHandler
All Implemented Interfaces:
IFormatHandler, StatusReporter
Direct Known Subclasses:
FormatReader, FormatWriter

public abstract class FormatHandler
extends Object
implements IFormatHandler

Abstract superclass of all biological file format readers and writers.

Source code:
Trac, SVN


Field Summary
protected  String currentId
          Name of current file.
static boolean debug
          Debugging flag.
static int debugLevel
          Debugging level. 1=basic, 2=extended, 3=everything, 4=insane.
protected  String format
          Name of this file format.
protected  Vector statusListeners
          List of status listeners.
protected  String[] suffixes
          Valid suffixes for this file format.
 
Constructor Summary
FormatHandler(String format, String suffix)
          Constructs a format handler with the given name and default suffix.
FormatHandler(String format, String[] suffixes)
          Constructs a format handler with the given name and default suffixes.
 
Method Summary
 void addStatusListener(StatusListener l)
          Adds a listener for status update events.
protected  void debug(String s)
          Issues a debugging statement.
 String getFormat()
          Gets the name of this file format.
 StatusListener[] getStatusListeners()
          Gets a list of all registered status update listeners.
 String[] getSuffixes()
          Gets the default file suffixes for this file format.
 boolean isThisType(String name)
          Checks if a file matches the type of this format handler.
 boolean isThisType(String name, boolean open)
          Checks if a file matches the type of this format handler.
 void removeStatusListener(StatusListener l)
          Removes a listener for status update events.
static void setDebug(boolean debug)
          Toggles debug mode (more verbose output and error messages).
static void setDebugLevel(int debugLevel)
          Toggles debug mode verbosity (which kinds of output are produced).
 void setId(String id)
          Sets the current file name.
protected  void status(int progress, int maximum, String message)
          Fires a status update event.
protected  void status(StatusEvent e)
          Fires a status update event.
protected  void status(String message)
          Fires a status update event.
protected  void trace(String s)
          Issues a stack trace.
protected  void trace(Throwable t)
          Issues a stack trace.
 
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
close, setId
 

Field Detail

debug

public static boolean debug
Debugging flag.


debugLevel

public static int debugLevel
Debugging level. 1=basic, 2=extended, 3=everything, 4=insane.


format

protected String format
Name of this file format.


suffixes

protected String[] suffixes
Valid suffixes for this file format.


statusListeners

protected Vector statusListeners
List of status listeners.


currentId

protected String currentId
Name of current file.

Constructor Detail

FormatHandler

public FormatHandler(String format,
                     String suffix)
Constructs a format handler with the given name and default suffix.


FormatHandler

public FormatHandler(String format,
                     String[] suffixes)
Constructs a format handler with the given name and default suffixes.

Method Detail

status

protected void status(String message)
Fires a status update event.


status

protected void status(int progress,
                      int maximum,
                      String message)
Fires a status update event.


status

protected void status(StatusEvent e)
Fires a status update event.


debug

protected void debug(String s)
Issues a debugging statement. Convenience method for format handlers.


trace

protected void trace(String s)
Issues a stack trace. Convenience method for format handlers.


trace

protected void trace(Throwable t)
Issues a stack trace. Convenience method for format handlers.


isThisType

public boolean isThisType(String name)
Checks if a file matches the type of this format handler. The default implementation checks filename suffixes against those known for this format.

Specified by:
isThisType in interface IFormatHandler

isThisType

public boolean isThisType(String name,
                          boolean open)
Checks if a file matches the type of this format handler. The default implementation checks filename suffixes against those known for this format (the open parameter does nothing).

Specified by:
isThisType in interface IFormatHandler
Parameters:
open - If true, and the file extension is insufficient to determine the file type, the (existing) file is opened for further analysis. Does nothing in the default implementation.

getFormat

public String getFormat()
Description copied from interface: IFormatHandler
Gets the name of this file format.

Specified by:
getFormat in interface IFormatHandler

getSuffixes

public String[] getSuffixes()
Description copied from interface: IFormatHandler
Gets the default file suffixes for this file format.

Specified by:
getSuffixes in interface IFormatHandler

setId

public void setId(String id)
           throws FormatException,
                  IOException
Description copied from interface: IFormatHandler
Sets the current file name.

Specified by:
setId in interface IFormatHandler
Throws:
FormatException
IOException

addStatusListener

public void addStatusListener(StatusListener l)
Description copied from interface: StatusReporter
Adds a listener for status update events.

Specified by:
addStatusListener in interface StatusReporter

removeStatusListener

public void removeStatusListener(StatusListener l)
Description copied from interface: StatusReporter
Removes a listener for status update events.

Specified by:
removeStatusListener in interface StatusReporter

getStatusListeners

public StatusListener[] getStatusListeners()
Description copied from interface: StatusReporter
Gets a list of all registered status update listeners.

Specified by:
getStatusListeners in interface StatusReporter

setDebug

public static void setDebug(boolean debug)
Toggles debug mode (more verbose output and error messages).


setDebugLevel

public static void setDebugLevel(int debugLevel)
Toggles debug mode verbosity (which kinds of output are produced).

Parameters:
debugLevel - 1=basic, 2=extended, 3=everything.