Class TPLutils

java.lang.Object
  extended byTPLutils

public class TPLutils
extends java.lang.Object


Constructor Summary
TPLutils()
           
 
Method Summary
static boolean checkName(java.lang.String variableName, java.util.Vector tplData)
          This method checks to see whether the intended variable name is a reserved word or a integer.
static int getInt(java.util.Vector tplData, java.lang.String temp, int lineCounter, int dataType)
          This method is to aid in CALCULATE and LET.
static java.lang.String getString(java.util.Vector tplData, java.lang.String temp, int lineCounter, int dataType)
          This method is to aid in CALCULATE and LET.
static java.lang.String readln()
          This method reads in input from the user and returns a String.
static int searchVector(java.util.Vector tplData, java.lang.String var)
          This method searches through the tplData Vector to find a specific variable.
static boolean str2bool(java.lang.String str2convert)
          This method converts a string to a boolean, or exits with an error message.
static int str2int(java.lang.String str2convert)
          This method converts a string to an integer.
static int variableType(java.util.Vector tplData, int index)
          This method takes the variable from the Vector at the specified index and returns the data type (INTEGER or STRING) of the variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TPLutils

public TPLutils()
Method Detail

searchVector

public static int searchVector(java.util.Vector tplData,
                               java.lang.String var)
This method searches through the tplData Vector to find a specific variable.

Parameters:
tplData - Contains the TPL variables, can be searched through. <TPLvariable> is the type of object that can be put into the Vector. (only in 1.5.0)
var - String containing the variable name to be searched for.
Returns:
The index of the variable which is being searched for. Else, it returns -1 if the variable does not exist.

variableType

public static int variableType(java.util.Vector tplData,
                               int index)
This method takes the variable from the Vector at the specified index and returns the data type (INTEGER or STRING) of the variable.

Parameters:
tplData - Contains the TPL variables, can be searched through.
index - The position of the variable in the Vector.
Returns:
The data type of the variable, for casting.

checkName

public static boolean checkName(java.lang.String variableName,
                                java.util.Vector tplData)
This method checks to see whether the intended variable name is a reserved word or a integer. If it is then it returns false as these are not allowed to be variable names (they could cause complications).

Parameters:
variableName - The variable name we are checking if allowed or not
tplData - Contains the TPL variables, can be searched through.
Returns:
True or false depending on whether the variable name is allowed or not

str2bool

public static boolean str2bool(java.lang.String str2convert)
This method converts a string to a boolean, or exits with an error message.

Parameters:
str2convert - The String that is to be converted to an integer.
Returns:
A boolean, or exit with an error message.

str2int

public static int str2int(java.lang.String str2convert)
This method converts a string to an integer. .valueOf returns an Integer - we call its .intValue to return an int.

Parameters:
str2convert - The String that is to be converted to an integer.
Returns:
An integer, or -9999 if there is an error. The error message could go in the try statement, but this method works better for the code.

getInt

public static int getInt(java.util.Vector tplData,
                         java.lang.String temp,
                         int lineCounter,
                         int dataType)
This method is to aid in CALCULATE and LET. It takes the argument supplied, checks if it is a variable and returns the data in that variable, if it is not a variable then it tries to convert it to an int, if this fails too then it throws an error.

Parameters:
tplData - Contains the TPL variables, can be searched through.
temp - The String from the CALCULATE/LET statement, which is either a variable name or an integer.
lineCounter - Counts the number of lines processed, shows where the error is.
dataType - The data type of the variable we are returning data to (here - 2)
Returns:
An integer for calculation/assigning, or an error (and exit).

getString

public static java.lang.String getString(java.util.Vector tplData,
                                         java.lang.String temp,
                                         int lineCounter,
                                         int dataType)
This method is to aid in CALCULATE and LET. It takes the argument supplied, checks if it is a variable and returns the data in that variable, if it is not a variable then it tries to convert it to an int, if this fails too then it throws an error.

Parameters:
tplData - Contains the TPL variables, can be searched through.
temp - The String from the CALCULATE/LET statement, which is either a variable name or an integer.
lineCounter - Counts the number of lines processed, shows where the error is.
dataType - The data type of the variable we are returning data to (here - 1)
Returns:
An String for calculation/assigning, or an error (and exit).

readln

public static java.lang.String readln()
This method reads in input from the user and returns a String.

Returns:
Input from user