|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.fedmest.cw.keyboard.validators.ValueTypeValidator<java.lang.Float>
com.fedmest.cw.keyboard.validators.FloatValidator
public final class FloatValidator
This class is used internally by the KeyboardUtils.readFloatFromKeyboard() methods. It is used as a singleton via
getInstance(). There is really no need to use it other than through KeyboardUtils.
| Field Summary |
|---|
| Fields inherited from class com.fedmest.cw.keyboard.validators.ValueTypeValidator |
|---|
errorMessage |
| Method Summary | |
|---|---|
java.lang.Float |
cancelValue()
Allows you to specify the return value to offer when the user cancels input on a cancelable instance of KeyboardUtils
. |
java.lang.Float |
checkInput(java.lang.String txt)
Takes the input string, checks its validity and converts it to the data type specified by the type argument. |
static FloatValidator |
getInstance()
Returns the only available instance of this class |
static void |
resetMax()
This method resets the maximum float value that will be accepted by this validator to the highest possible float value. |
static void |
resetMin()
This method resets the minimum float value that will be accepted by this validator to the lowest possible float value. |
static void |
resetRange()
This method resets the minimum and maximum float values that will be accepted by this validator to the lowest and highest possible float values respectively. |
static void |
resetRangeMessage()
This method resets to the default text the error message that will be displayed to users when the value is out of range ("Value out of range - retry"). |
static void |
setMax(float max)
This method sets the maximum float value that will be accepted by this validator. |
static void |
setMin(float min)
This method sets the minimum float value that will be accepted by this validator. |
static void |
setRange(float min,
float max)
This method sets the maximum and minimum float values that will be accepted by this validator. |
static void |
setRangeMessage(java.lang.String rangeMessage)
This method sets the error message that will be displayed to the user if validation fails due to a value being outside of the range specified with setMax(float), setMin(float) or setRange(float, float). |
| Methods inherited from class com.fedmest.cw.keyboard.validators.ValueTypeValidator |
|---|
resetErrorMessage, setErrorMessage |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void setRangeMessage(java.lang.String rangeMessage)
setMax(float), setMin(float) or setRange(float, float). Invoke it
before you call any method in KeyboardUtils that uses a class in this validator hierarchy to customize the error
message that will be used. Note that the message applies to all subclasses of this class and will be used until reset with
resetRangeMessage() or changed with this method again.
rangeMessage - the new error message to display to userspublic static void resetRangeMessage()
setRangeMessage(String)public static void setMax(float max)
max parameter.
max - the maximum float value allowed in parsing (inclusive)public static void resetMax()
setMax(float)public static void setMin(float min)
min parameter.
min - the minimum float value allowed in parsing (inclusive)public static void resetMin()
setMin(float)
public static void setRange(float min,
float max)
min and max parameters.
Invoking this method is equivalent to invoking setMin(float) and setMax(float).
min - the minimum float value allowed in parsing (inclusive)max - the maximum float value allowed in parsing (inclusive)setMin(float),
setMax(float)public static void resetRange()
setMin(float),
setMax(float),
resetMin(),
resetMax()public static FloatValidator getInstance()
public java.lang.Float checkInput(java.lang.String txt)
throws KeyboardInputException
KeyboardInputValidatorKeyboardInputException is raised and the user will have to type their input again. If a null
reference is passed into the method, the method may throw a NullPointerException, so programmers do not need to worry
about checking for null pointers.
txt - the input text. If the string is null, NullPointerException will be thrown.
KeyboardInputException - if validation against the input string failedpublic java.lang.Float cancelValue()
KeyboardInputValidatorKeyboardUtils
. Though null should be returned in most cases, this method is useful when - for example - you want to return a
primitive type from your validator and can't use null as a return value without causing a bit of inconvenienve in
your application code (explicit unboxing and checks for null values).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||