BioLegato 0.7.5 GDE plugin

org.biolegato.gdesupport.files
Class DataFormat

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.biolegato.gdesupport.files.DataFormat
Direct Known Subclasses:
FastAFile, GDEFile, GDEFlatfile, GenBankFile2008

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

Class to represent reading of data formats.

Author:
Graham Alvare, Brian Fristensky

Field Summary
static DataFormat FASTA
           
static DataFormat[] FORMAT_LIST
          The list of available file formats
static DataFormat GDEFILE
           
static DataFormat GDEFLAT
           
static DataFormat GENBANK
           
 
Constructor Summary
DataFormat()
          Creates a new instance of DataFormat
 
Method Summary
static DataFormat autodetect(java.io.BufferedReader data)
          Used to auto-detect file formats.
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
static void readFile(Dataset datamodel, DataFormat format, java.io.File file)
          Reads a file into the canvas
static void readFile(Dataset datamodel, java.io.File file)
          Reads a file into the canvas
abstract  void translateFrom(Dataset datamodel, java.io.BufferedReader data)
          Translates a string from the given file format into the BioLegato internal format.
abstract  void translateTo(java.lang.Appendable destination, Seq data, int offset, int length)
          Translates a string from the BioLegato internal format to the given file format.
static void writeAll(Dataset datamodel, DataFormat format, java.io.File file)
          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
 

Field Detail

GENBANK

public static final DataFormat GENBANK

GDEFILE

public static final DataFormat GDEFILE

GDEFLAT

public static final DataFormat GDEFLAT

FASTA

public static final DataFormat FASTA

FORMAT_LIST

public static final DataFormat[] FORMAT_LIST
The list of available file formats

Constructor Detail

DataFormat

public DataFormat()
Creates a new instance of DataFormat

Method Detail

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 void translateTo(java.lang.Appendable destination,
                                 Seq data,
                                 int offset,
                                 int length)
                          throws java.io.IOException
Translates a string from the BioLegato internal format to the given file format.

Parameters:
data - the string to convert
Throws:
java.io.IOException

translateFrom

public abstract void translateFrom(Dataset datamodel,
                                   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.
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 the format is correct

autodetect

public static DataFormat autodetect(java.io.BufferedReader data)
Used to auto-detect file formats.

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

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).

readFile

public static void readFile(Dataset datamodel,
                            java.io.File file)
                     throws java.io.IOException
Reads a file into the canvas

Parameters:
format - the file format to use for parsing the file.
currentFile - the file to read in.
Throws:
java.io.IOException

readFile

public static void readFile(Dataset datamodel,
                            DataFormat format,
                            java.io.File file)
Reads a file into the canvas

Parameters:
format - the file format to use for parsing the file.
currentFile - the file to read in.

writeAll

public static void writeAll(Dataset datamodel,
                            DataFormat format,
                            java.io.File file)
                     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

BioLegato 0.7.5 GDE plugin

Copyright © 2008-2011 University of Manitoba.