io.g96.in
Class InBlock

java.lang.Object
  extended byio.g96.in.InBlock
Direct Known Subclasses:
InCorG96, InEnergiesG96

public class InBlock
extends java.lang.Object

Author:
vincent

Field Summary
(package private)  java.util.regex.Pattern endPattern
           
(package private)  java.lang.String fileName
           
(package private)  java.util.regex.Pattern startPattern
           
(package private)  java.io.BufferedReader stream
           
(package private)  java.util.StringTokenizer tok
           
 
Constructor Summary
InBlock()
           
InBlock(java.lang.String fn)
           
 
Method Summary
static void assertBlockName(java.util.ArrayList block, java.lang.String blockName)
          check the block name (first line) of a block.
static void assertBlockSize(java.util.ArrayList block, int size)
          perform a consistency check between the
the number of lines a given block was espected to have and the
number that was actually read in
 void close()
          close the file stream and reset the file name
 java.util.HashMap getBlocks(java.util.ArrayList blockNames)
          read blocks until all blocks corresponding to the block names have been read.
 java.util.ArrayList getNextBlock()
           
 void open(java.lang.String fn)
           
static double[] parseDoubleArray(java.lang.String line)
          parse an array of doubles from a string.
static double[] parseDoubleArray(java.lang.String[] lines)
          parse an array of doubles from an array of strings, one double per string.
static double[] parseDoubleArray(java.lang.String line, int length)
           
static double[][] parseDoubleMatrix(java.lang.String[] lines, int nCols)
          parse an matrix of doubles from an array of strings, nCols doubles per line.
 java.lang.String readTitle()
          Gromos files are usually headed by a TITLE block.
(package private)  boolean skipLine(java.lang.String line)
           
 java.util.ArrayList slurp()
          slurp the whole contents of the file into a list of blocks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

java.lang.String fileName

stream

java.io.BufferedReader stream

tok

java.util.StringTokenizer tok

startPattern

java.util.regex.Pattern startPattern

endPattern

java.util.regex.Pattern endPattern
Constructor Detail

InBlock

public InBlock()
        throws java.io.IOException

InBlock

public InBlock(java.lang.String fn)
        throws java.io.IOException
Method Detail

open

public void open(java.lang.String fn)
          throws java.io.IOException
Parameters:
fn -
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
close the file stream and reset the file name

Throws:
java.io.IOException

getNextBlock

public java.util.ArrayList getNextBlock()
                                 throws java.io.IOException
Returns:
the next GROMOS-Block from the stream
Throws:
java.io.IOException

readTitle

public java.lang.String readTitle()
                           throws java.io.IOException
Gromos files are usually headed by a TITLE block. Use this function to attempt to read it.

Returns:
String[] the title block as lines.
Throws:
java.io.IOException

assertBlockSize

public static final void assertBlockSize(java.util.ArrayList block,
                                         int size)
perform a consistency check between the
the number of lines a given block was espected to have and the
number that was actually read in

Parameters:
block -
size -

assertBlockName

public static final void assertBlockName(java.util.ArrayList block,
                                         java.lang.String blockName)
check the block name (first line) of a block.

Parameters:
block -
blockName -

skipLine

boolean skipLine(java.lang.String line)

parseDoubleMatrix

public static double[][] parseDoubleMatrix(java.lang.String[] lines,
                                           int nCols)
parse an matrix of doubles from an array of strings, nCols doubles per line.

Parameters:
lines -
nCols -
Returns:
the matrix

parseDoubleArray

public static double[] parseDoubleArray(java.lang.String[] lines)
parse an array of doubles from an array of strings, one double per string.

Parameters:
lines -
Returns:
the array

parseDoubleArray

public static double[] parseDoubleArray(java.lang.String line)
parse an array of doubles from a string.

Parameters:
line -
Returns:
the array

parseDoubleArray

public static double[] parseDoubleArray(java.lang.String line,
                                        int length)
Parameters:
line -
length - line must contain this many numbers
Returns:
the array

getBlocks

public java.util.HashMap getBlocks(java.util.ArrayList blockNames)
                            throws java.io.IOException
read blocks until all blocks corresponding to the block names have been read.

Parameters:
blockNames -
Returns:
the bloockNames -> blocks map
Throws:
java.io.IOException

slurp

public java.util.ArrayList slurp()
                          throws java.io.IOException
slurp the whole contents of the file into a list of blocks

Returns:
the list of blocks
Throws:
java.io.IOException