pal.io
Class FormattedInput

java.lang.Object
  |
  +--pal.io.FormattedInput
All Implemented Interfaces:
java.io.Serializable

public class FormattedInput
extends java.lang.Object
implements java.io.Serializable

tools to simplify formatted input from an input stream

See Also:
Serialized Form

Method Summary
static FormattedInput getInstance()
          create new instance of this object (note that there is no public constructor because this class is a singleton!)
 void nextLine(java.io.PushbackReader in)
          go to the beginning of the next line.
 double readDouble(java.io.PushbackReader in)
          read next number from stream and convert it to a double (newline/cr are treated as separators)
 double readDouble(java.io.PushbackReader in, boolean ignoreNewlineCR)
          read next number from stream and convert it to a double
 int readInt(java.io.PushbackReader in)
          read next number from stream and convert it to a int (newline/cr are treated as separators)
 int readInt(java.io.PushbackReader in, boolean ignoreNewlineCR)
          read next number from stream and convert it to a int
 java.lang.String readLabel(java.io.PushbackReader in, int maxLength)
          read sequence label from stream A sequence label is not allowed to contain whitespace and either of :,;()[]{}.
 java.lang.String readLine(java.io.PushbackReader in, boolean keepWhiteSpace)
          read a whole line
 int readNextChar(java.io.PushbackReader input)
          read next character from stream (EOF does not count as character but will throw exception)
 java.lang.String readNumber(java.io.PushbackReader in, boolean ignoreNewlineCR)
           
 java.lang.String readWord(java.io.PushbackReader in)
          read word from stream
 int skipWhiteSpace(java.io.PushbackReader in)
          go to first non-whitespace character
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static FormattedInput getInstance()
create new instance of this object (note that there is no public constructor because this class is a singleton!)

nextLine

public void nextLine(java.io.PushbackReader in)
              throws java.io.IOException
go to the beginning of the next line. Recognized line terminators: Unix: \n, DOS: \r\n, Macintosh: \r
Parameters:
in - input stream

readLine

public java.lang.String readLine(java.io.PushbackReader in,
                                 boolean keepWhiteSpace)
                          throws java.io.IOException
read a whole line
Parameters:
in - input stream
keepWhiteSpace - keep or drop white space
Returns:
string with content of line

skipWhiteSpace

public int skipWhiteSpace(java.io.PushbackReader in)
                   throws java.io.IOException
go to first non-whitespace character
Parameters:
in - input stream
Returns:
character or EOF

readNextChar

public int readNextChar(java.io.PushbackReader input)
                 throws java.io.IOException
read next character from stream (EOF does not count as character but will throw exception)
Parameters:
input - input stream
Returns:
character

readWord

public java.lang.String readWord(java.io.PushbackReader in)
                          throws java.io.IOException
read word from stream
Parameters:
input - stream
Returns:
word read from stream

readLabel

public java.lang.String readLabel(java.io.PushbackReader in,
                                  int maxLength)
                           throws java.io.IOException
read sequence label from stream A sequence label is not allowed to contain whitespace and either of :,;()[]{}. Note that newline/cr is NOT counted as white space!!
Parameters:
in - input stream
maxLength - maximum allowed length of label (if negative any length is permitted)
Returns:
label

readNumber

public java.lang.String readNumber(java.io.PushbackReader in,
                                   boolean ignoreNewlineCR)
                            throws java.io.IOException

readDouble

public double readDouble(java.io.PushbackReader in)
                  throws java.io.IOException,
                         java.lang.NumberFormatException
read next number from stream and convert it to a double (newline/cr are treated as separators)
Parameters:
in - input stream
Returns:
double

readDouble

public double readDouble(java.io.PushbackReader in,
                         boolean ignoreNewlineCR)
                  throws java.io.IOException,
                         java.lang.NumberFormatException
read next number from stream and convert it to a double
Parameters:
in - input stream
ignoreNewlineCR - ignore newline/cr as separator
Returns:
double

readInt

public int readInt(java.io.PushbackReader in)
            throws java.io.IOException,
                   java.lang.NumberFormatException
read next number from stream and convert it to a int (newline/cr are treated as separators)
Parameters:
in - input stream
Returns:
integer

readInt

public int readInt(java.io.PushbackReader in,
                   boolean ignoreNewlineCR)
            throws java.io.IOException,
                   java.lang.NumberFormatException
read next number from stream and convert it to a int
Parameters:
in - input stream
ignoreNewlineCR - ignore newline/cr as separator
Returns:
integer