de.jstacs.io
Class StringExtractor

java.lang.Object
  extended by de.jstacs.io.StringExtractor

public class StringExtractor
extends Object

This class implements the reader that extracts strings from either a file or a string. The class ignores lines starting with a given character, since those lines are treated as comments. If the user does not specify this character, it is set to "#" internally. If the user specifies this character as ">", the file or String will be treated as in FastA-format, i.e. lines beginning with > will be stripped and the lines between two > (or until the end of the file) will be appended to form a new String.

Author:
Jan Grau, Jens Keilwagen

Field Summary
static char FASTA
          The comment-character for FastA-formatted files is '>'.
static char USUALLY
          The usual comment-character is #.
 
Constructor Summary
StringExtractor(File file, int initSize)
          A constructor that reads the lines from file.
StringExtractor(File file, int initSize, char ignore)
          A constructor that reads the lines from file and ignores those starting with ignore.
StringExtractor(File file, int initSize, char ignore, String annotation)
          A constructor that reads the lines from file and ignores those starting with ignore.
StringExtractor(File file, int initSize, String annotation)
          A constructor that reads the lines from file .
StringExtractor(String content, int initSize, char ignore, String annotation)
          A constructor that reads the lines from a String content and ignores those starting with ignore
StringExtractor(String content, int initSize, String annotation)
          A constructor that reads the lines from a String content.
 
Method Summary
 String getAnnotation()
          Returns the annotation of the source.
 int getNumberOfStrings()
          Returns the number of strings
 String getString(int i)
          Returns the string with index i.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USUALLY

public static char USUALLY
The usual comment-character is #. Lines beginning with this sign will be ignored.


FASTA

public static char FASTA
The comment-character for FastA-formatted files is '>'. If '>' is specified as the comment-character, the file or String will be interpreted as in FastA format.

Constructor Detail

StringExtractor

public StringExtractor(File file,
                       int initSize)
                throws IOException,
                       FileNotFoundException
A constructor that reads the lines from file.

Parameters:
file - the file to be read from
initSize - the inital number of lines the can be handled
Throws:
IOException - is thrown if the file could not be read
FileNotFoundException - is thrown if the file could not be found

StringExtractor

public StringExtractor(File file,
                       int initSize,
                       char ignore)
                throws IOException,
                       FileNotFoundException
A constructor that reads the lines from file and ignores those starting with ignore.

Parameters:
file - the file to be read from
initSize - the inital number of lines the can be handled
ignore - the first character of lines that should be treated as comments
Throws:
IOException - is thrown if the file could not be read
FileNotFoundException - is thrown if the file could not be found

StringExtractor

public StringExtractor(File file,
                       int initSize,
                       String annotation)
                throws IOException,
                       FileNotFoundException
A constructor that reads the lines from file .

Parameters:
file - the file to be read from
initSize - the inital number of lines the can be handled
annotation - the annotation for the source
Throws:
IOException - is thrown if the file could not be read
FileNotFoundException - is thrown if the file could not be found

StringExtractor

public StringExtractor(File file,
                       int initSize,
                       char ignore,
                       String annotation)
                throws IOException,
                       FileNotFoundException
A constructor that reads the lines from file and ignores those starting with ignore.

Parameters:
file - the file to be read from
initSize - the inital number of lines the can be handled
ignore - the first character of lines that should be treated as comments
annotation - the annotation for the source
Throws:
IOException - is thrown if the file could not be read
FileNotFoundException - is thrown if the file could not be found

StringExtractor

public StringExtractor(String content,
                       int initSize,
                       String annotation)
A constructor that reads the lines from a String content.

Parameters:
content - the complete String with all lines
initSize - the inital number of lines the can be handled
annotation - some annotation for the content

StringExtractor

public StringExtractor(String content,
                       int initSize,
                       char ignore,
                       String annotation)
A constructor that reads the lines from a String content and ignores those starting with ignore

Parameters:
content - the complete String with all lines
initSize - the inital number of lines the can be handled
ignore - the first character of lines that should be treated as comments
annotation - some annotation for the content
Method Detail

getString

public String getString(int i)
Returns the string with index i.

Parameters:
i - the index
Returns:
the string with index i

getNumberOfStrings

public int getNumberOfStrings()
Returns the number of strings

Returns:
the number of strings

getAnnotation

public String getAnnotation()
Returns the annotation of the source.

Returns:
the annotation