de.jstacs.io
Class StringExtractor

java.lang.Object
  extended by de.jstacs.io.AbstractStringExtractor
      extended by de.jstacs.io.StringExtractor
All Implemented Interfaces:
Enumeration<String>

public class StringExtractor
extends AbstractStringExtractor

This class implements the reader that extracts strings from either a file or a string. Internally the String are extract and stored in an array when creating an new instance.

Author:
Jan Grau, Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.io.AbstractStringExtractor
annotation, FASTA, ignore, ignorePattern, USUALLY
 
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 getElement(int idx)
          Returns String no idx that has been extracted.
 int getNumberOfElements()
          Returns the number of Strings that have been read.
 boolean hasMoreElements()
           
 String nextElement()
           
 
Methods inherited from class de.jstacs.io.AbstractStringExtractor
getAnnotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 initial 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 initial 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 initial 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 initial 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 initial 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 initial 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

nextElement

public String nextElement()

hasMoreElements

public boolean hasMoreElements()

getNumberOfElements

public int getNumberOfElements()
Returns the number of Strings that have been read.

Returns:
the number of Strings

getElement

public String getElement(int idx)
Returns String no idx that has been extracted.

Parameters:
idx - the number of the String
Returns:
String no idx