Class DataParser

java.lang.Object
  extended by DataParser

public class DataParser
extends java.lang.Object

Parses data from a string or text file. The input data format is not documented here yet. Sorry!


Constructor Summary
DataParser()
          Constructs a data parser with default state.
 
Method Summary
 java.lang.StringBuilder createStringFromFile(java.lang.String filename)
          Creates a single character string from a file.
 javax.vecmath.Color3f getColor3f()
          Gets a color and advances the token stream.
 double getDouble()
          Gets a double and advances the token stream.
 float getFloat()
          Gets a float and advances the token stream.
 int getInteger()
          Gets an integer and advances the token stream.
 javax.vecmath.Point3d getPoint3d()
          Gets a point and advances the token stream.
 java.lang.String getString()
          Gets a string and advances the token stream.
 javax.vecmath.Vector3d getVector3d()
          Gets a vector and advances the token stream.
 boolean parse(java.lang.CharSequence input, java.lang.String regularExpression)
          Parses the input sequence using the specified regular expression, and sets the data parser to the first token.
 boolean parseFile(java.lang.String filename, java.lang.String regularExpression)
          Parses data from a file.
 boolean parseString(java.lang.String dataString, java.lang.String regularExpression)
          Parses data from a string.
 boolean tokensRemaining()
          Checks whether there are any tokens remaining.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataParser

public DataParser()
Constructs a data parser with default state.

Method Detail

parse

public boolean parse(java.lang.CharSequence input,
                     java.lang.String regularExpression)
Parses the input sequence using the specified regular expression, and sets the data parser to the first token.

Parameters:
input - The character data to parse.
regularExpression - The regular expression used to parse the character data.
Returns:
Returns {code true} if successful, {code false} otherwise.

parseString

public boolean parseString(java.lang.String dataString,
                           java.lang.String regularExpression)
Parses data from a string.

Parameters:
dataString - The character data to parse.
regularExpression - The regular expression to parse the character data with.
Returns:
Returns {code true} if successful, {code false} otherwise.

parseFile

public boolean parseFile(java.lang.String filename,
                         java.lang.String regularExpression)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Parses data from a file.

Parameters:
filename - The name of the file with character data to parse.
regularExpression - The regular expression to parse the file with.
Returns:
Returns {code true} if successful, {code false} otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

createStringFromFile

public java.lang.StringBuilder createStringFromFile(java.lang.String filename)
                                             throws java.io.FileNotFoundException,
                                                    java.io.IOException
Creates a single character string from a file.

Parameters:
filename - The name of the file to create a string out of.
Returns:
The string containing the file contents.
Throws:
java.io.FileNotFoundException
java.io.IOException

tokensRemaining

public boolean tokensRemaining()
Checks whether there are any tokens remaining.

Returns:
Returns {code true} if there are more tokens, otherwise {code false}.

getInteger

public int getInteger()
Gets an integer and advances the token stream.

Returns:
An integer value.

getDouble

public double getDouble()
Gets a double and advances the token stream.

Returns:
A double value.

getFloat

public float getFloat()
Gets a float and advances the token stream.

Returns:
A float value.

getString

public java.lang.String getString()
Gets a string and advances the token stream.

Returns:
A string value.

getVector3d

public javax.vecmath.Vector3d getVector3d()
Gets a vector and advances the token stream.

Returns:
A vector value.

getPoint3d

public javax.vecmath.Point3d getPoint3d()
Gets a point and advances the token stream.

Returns:
A point value.

getColor3f

public javax.vecmath.Color3f getColor3f()
Gets a color and advances the token stream.

Returns:
A color value.