BioLegato 0.7.0 Core API

org.biolegato.core.plugintypes
Class DataFormat

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.biolegato.core.plugintypes.DataFormat

public abstract class DataFormat
extends javax.swing.filechooser.FileFilter

Class to represent reading of data formats.

Author:
Graham Alvare, Brian Fristensky

Constructor Summary
DataFormat()
          Creates a new instance of DataFormat
 
Method Summary
static void addFormats(javax.swing.JFileChooser filechooser, java.lang.String defaultFormat)
          This function loads all of the available file formats into a JFileChooser.
static Sequence[] auto(java.io.BufferedReader data)
          Used to auto-detect and parse data into BioLegato sequence objects.
static Sequence[] auto(java.io.File file)
          Used to auto-detect and parse files into BioLegato sequence objects.
static Sequence[] auto(java.io.InputStream stream)
          Used to auto-detect and parse an input stream's data into BioLegato sequence objects.
static DataFormat getFormat(java.lang.String hashname)
          Finds the filetype that corresponds to the given hashname (null if not successful).
 java.lang.String getName()
          Obtains the name of the file format for File Chooser purposes
abstract  boolean isFormat(java.io.Reader test)
          Used to auto-detect Bio Legato formats
 Sequence[] readFile(java.io.File file)
          Reads a file's contained sequences using the file filter's translation.
abstract  Sequence[] translateFrom(java.io.BufferedReader data)
          Translates a string from the given file format into the BioLegato internal format.
abstract  java.lang.String translateTo(Sequence data)
          Translates a string from the BioLegato internal format to the given file format.
 void writeFile(java.io.File file, Sequence[] data)
          Writes a list of sequences to a file.
 
Methods inherited from class javax.swing.filechooser.FileFilter
accept, getDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataFormat

public DataFormat()
Creates a new instance of DataFormat

Method Detail

addFormats

public static void addFormats(javax.swing.JFileChooser filechooser,
                              java.lang.String defaultFormat)
This function loads all of the available file formats into a JFileChooser.

Parameters:
filechooser - the JFileChooser to load the formats into.
defaultFormat - the default file format for the file chooser.

readFile

public Sequence[] readFile(java.io.File file)
                    throws java.io.IOException
Reads a file's contained sequences using the file filter's translation.

Parameters:
file - the file to writer to.
Returns:
the contents of the file
Throws:
java.io.IOException - passes any exceptions from reading the file

writeFile

public void writeFile(java.io.File file,
                      Sequence[] data)
               throws java.io.IOException
Writes a list of sequences to a file.

Parameters:
file - the file to writer to.
data - the contents to writer.
Throws:
java.io.IOException - throws any exceptions that occur while writing to the file

getName

public java.lang.String getName()
Obtains the name of the file format for File Chooser purposes

Returns:
the name of the file format

translateTo

public abstract java.lang.String translateTo(Sequence data)
Translates a string from the BioLegato internal format to the given file format.

Parameters:
data - the string to convert
Returns:
the resulting string

translateFrom

public abstract Sequence[] translateFrom(java.io.BufferedReader data)
                                  throws java.io.IOException
Translates a string from the given file format into the BioLegato internal format.

Parameters:
data - the string to convert.
Returns:
the resulting string.
Throws:
java.io.IOException - any exeptions that occur while reading the stream are passed.

isFormat

public abstract boolean isFormat(java.io.Reader test)
Used to auto-detect Bio Legato formats

Parameters:
test - the string to test
Returns:
whether or not the format is correct

getFormat

public static DataFormat getFormat(java.lang.String hashname)
Finds the filetype that corresponds to the given hashname (null if not successful).

Parameters:
hashname - the hashname to search for.
Returns:
The result of the search (returns null on failure).

auto

public static Sequence[] auto(java.io.File file)
Used to auto-detect and parse files into BioLegato sequence objects.

Parameters:
file - the file to read.
Returns:
The resulting sequences.

auto

public static Sequence[] auto(java.io.InputStream stream)
Used to auto-detect and parse an input stream's data into BioLegato sequence objects.

Parameters:
stream - the stream to read.
Returns:
The resulting sequences.

auto

public static Sequence[] auto(java.io.BufferedReader data)
Used to auto-detect and parse data into BioLegato sequence objects.

Parameters:
data - the string to convert
Returns:
The resulting sequences.

BioLegato 0.7.0 Core API

Copyright © 2008-2010 University of Manitoba.