org.biojava.bio.program.gff
Class GFFParser

java.lang.Object
  |
  +--org.biojava.bio.program.gff.GFFParser

public class GFFParser
extends java.lang.Object

Parse a stream of GFF text into a stream of records and comments.

Author:
Matthew Pocock, Thomas Down

Constructor Summary
GFFParser()
           
 
Method Summary
protected  GFFRecord createRecord(GFFDocumentHandler handler, java.util.List aList, java.lang.String rest, java.lang.String comment)
          Actualy turns a list of tokens, some value string and a comment into a GFFRecord and informs handler.
 GFFErrorHandler getErrorHandler()
          Find the error handler used by this parser.
 void parse(java.io.BufferedReader bReader, GFFDocumentHandler handler)
          Informs handler of each line of gff read from bReader.
 void parse(java.io.BufferedReader bReader, GFFDocumentHandler handler, java.lang.String locator)
          Informs handler of each line of gff read from bReader
protected  java.util.Map parseAttribute(java.lang.String attValList)
          Parse attValList into a Map of attributes and value lists.
 void setErrorHandler(GFFErrorHandler errors)
          Set the error handler used by this parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GFFParser

public GFFParser()
Method Detail

setErrorHandler

public void setErrorHandler(GFFErrorHandler errors)
Set the error handler used by this parser.

getErrorHandler

public GFFErrorHandler getErrorHandler()
Find the error handler used by this parser.

parse

public void parse(java.io.BufferedReader bReader,
                  GFFDocumentHandler handler)
           throws java.io.IOException,
                  BioException,
                  ParserException
Informs handler of each line of gff read from bReader. This form of the method should only be used if no locator string is available for the resource being parsed.
Parameters:
bReader - the BufferedReader to parse
handler - the GFFDocumentHandler that will listen for 'stuff'
Throws:
IOException if for any reason bReader throws one
BioException if handler can not correct a parse error

parse

public void parse(java.io.BufferedReader bReader,
                  GFFDocumentHandler handler,
                  java.lang.String locator)
           throws java.io.IOException,
                  BioException,
                  ParserException
Informs handler of each line of gff read from bReader
Parameters:
bReader - the BufferedReader to parse
handler - the GFFDocumentHandler that will listen for 'stuff'
Throws:
IOException if for any reason bReader throws one
BioException if handler can not correct a parse error

createRecord

protected GFFRecord createRecord(GFFDocumentHandler handler,
                                 java.util.List aList,
                                 java.lang.String rest,
                                 java.lang.String comment)
                          throws BioException,
                                 ParserException,
                                 IgnoreRecordException
Actualy turns a list of tokens, some value string and a comment into a GFFRecord and informs handler.
Parameters:
handler - a GFFDocumentHandler to inform of any parse errors, and the completed GFFRecord
aList - a List containing the 8 mandatory GFF columns
rest - a String representing the unparsed attribute-value text, or null if there is none
comment - a String containing the comment (without the leading '#' character.
Throws:
BioException if handler could not correct a parse error

parseAttribute

protected java.util.Map parseAttribute(java.lang.String attValList)
Parse attValList into a Map of attributes and value lists.

The resulting Map will have String keys, with List values. If there are no values associated with a key, then it will have an empty List, not null as its value.

Parameters:
attValList - the String to parse
Returns:
a Map of parsed attributes and value lists