public class ASTInt
extends java.lang.Object
This class is useful because Java passes all parameters to a method by value. Hence, in Java one cannot have a statement such as
bValid = isValidReal(String inputStr, double dResult)
where the isValidReal
method returns a validity (true/false) and
modifies dResult
to have the value parsed from inputStr
.
Passing objects rather than primitives such as double avoids this problem.
Copyright (c) 2018
Constructor and Description |
---|
ASTInt()
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getIntValue()
Gets the integer value in the object
|
static ASTInt |
isValidInt(java.lang.String inputStr)
Check to see if a valid integer was entered, but don't
display any error messages unless flag is SHOW_ERRORS.
|
static ASTInt |
isValidInt(java.lang.String inputStr,
boolean flag)
Check to see if a valid integer was entered, but don't
display any error messages unless flag is SHOW_ERRORS.
|
boolean |
isValidIntObj()
Returns whether the object is a valid integer
|
void |
setIntValue(int N)
Sets the integer value in the object
|
void |
setValidIntObj(boolean flag)
Sets whether the object is a valid integer
|
public ASTInt()
Since much of the usage of this class involves validating that a string has a valid integer, assume a new object is invalid until it is proven otherwise.
public boolean isValidIntObj()
public int getIntValue()
public void setIntValue(int N)
N
- value to setpublic void setValidIntObj(boolean flag)
flag
- whether the object is a valid integerpublic static ASTInt isValidInt(java.lang.String inputStr)
This method is overloaded to allow the flag for whether to display error messages to be optional. The default is to show error messages.
inputStr
- string to be validatedpublic static ASTInt isValidInt(java.lang.String inputStr, boolean flag)
This method is overloaded to allow the flag for whether to display error messages to be optional. The default is to show error messages.
inputStr
- string to be validatedflag
- whether to display error messages