gov.sandia.cognition.math.matrix
Class VectorReader

java.lang.Object
  extended by gov.sandia.cognition.math.matrix.VectorReader

@CodeReview(reviewer="Jonathan McClain",
            date="2006-05-22",
            changesNeeded=true,
            comments="Changes marked by triple slash",
            response=@CodeReviewResponse(respondent="Justin Basilico",date="2006-07-20",moreChangesNeeded=false,comments="Changes from J.T.\'s code review"))
public class VectorReader
extends Object

Reads a Vector from a single line in a file

Since:
1.0
Author:
Kevin R. Dixon

Field Summary
static String COMMENT_LINE_PREFIX
          The start of a comment line has the "#" string at the beginning.
 
Constructor Summary
VectorReader(Reader reader)
          Creates a new instance of VectorReader
VectorReader(ReaderTokenizer tokenizer)
          Creates a new instance of VectorReader
 
Method Summary
protected  ReaderTokenizer getTokenizer()
          Getter for tokenizer
static Vector parseVector(Collection<String> tokens)
          Parses a Vector from the given list of element tokens.
 Vector read()
          Reads a Vector off of the next line in the file
 List<Vector> readCollection(boolean mustBeSameSize)
          Reads a collection of Vectors from the Reader
protected  void setTokenizer(ReaderTokenizer tokenizer)
          Setter for tokenizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMENT_LINE_PREFIX

public static final String COMMENT_LINE_PREFIX
The start of a comment line has the "#" string at the beginning.

See Also:
Constant Field Values
Constructor Detail

VectorReader

public VectorReader(Reader reader)
Creates a new instance of VectorReader

Parameters:
reader - Java-based reader from which to pull the Vector

VectorReader

public VectorReader(ReaderTokenizer tokenizer)
Creates a new instance of VectorReader

Parameters:
tokenizer - Parses the input stream and pulls out tokens
Method Detail

read

public Vector read()
            throws IOException
Reads a Vector off of the next line in the file

Returns:
Vector that is on the next line in the file, or null if no values were found
Throws:
IOException - on a bad readLine on the BufferedReader

parseVector

public static Vector parseVector(Collection<String> tokens)
Parses a Vector from the given list of element tokens.

Parameters:
tokens - The collection of element tokens.
Returns:
A new Vector created from the given tokens.

readCollection

public List<Vector> readCollection(boolean mustBeSameSize)
                            throws IOException
Reads a collection of Vectors from the Reader

Parameters:
mustBeSameSize - true if the Vectors must be same size, false allows any sized Vectors in the List
Returns:
List of Vectors, where the nth Vector was the nth row in the Reader
Throws:
IOException - if the Reader isn't valid or doesn't contain a Vector

getTokenizer

protected ReaderTokenizer getTokenizer()
Getter for tokenizer

Returns:
Parses the input stream and pulls out tokens

setTokenizer

protected void setTokenizer(ReaderTokenizer tokenizer)
Setter for tokenizer

Parameters:
tokenizer - Parses the input stream and pulls out tokens