|
||||||||||
| 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.Long>
com.fedmest.cw.keyboard.validators.LongValidator
public final class LongValidator
This class is used internally by the KeyboardUtils.readLongFromKeyboard() 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.Long |
cancelValue()
Allows you to specify the return value to offer when the user cancels input on a cancelable instance of KeyboardUtils
. |
java.lang.Long |
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 LongValidator |
getInstance()
Returns the only available instance of this class |
static void |
resetMax()
This method resets the maximum long value that will be accepted by this validator to the highest possible long value. |
static void |
resetMin()
This method resets the minimum long value that will be accepted by this validator to the lowest possible long value. |
static void |
resetRadix()
This method resets the number base to 10 (decimal numbers). |
static void |
resetRange()
This method resets the minimum and maximum long values that will be accepted by this validator to the lowest and highest possible long 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(long max)
This method sets the maximum long value that will be accepted by this validator. |
static void |
setMin(long min)
This method sets the minimum long value that will be accepted by this validator. |
static void |
setRadix(int radix)
This method sets the number base that will be used the next time you pass this class to KeyboardUtils for validation. |
static void |
setRange(long min,
long max)
This method sets the maximum and minimum long 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(long), setMin(long) or setRange(long, long). |
| 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(long), setMin(long) or setRange(long, long). 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(long max)
max parameter.
max - the maximum long value allowed in parsing (inclusive)public static void resetMax()
setMax(long)public static void setMin(long min)
min parameter.
min - the minimum long value allowed in parsing (inclusive)public static void resetMin()
setMin(long)
public static void setRange(long min,
long max)
min and max parameters.
Invoking this method is equivalent to invoking setMin(long) and setMax(long).
min - the minimum long value allowed in parsing (inclusive)max - the maximum long value allowed in parsing (inclusive)setMin(long),
setMax(long)public static void resetRange()
setMin(long),
setMax(long),
resetMin(),
resetMax()public static void setRadix(int radix)
KeyboardUtils for validation.
Note that the methods that use this validator in KeyboardUtils already deal with the radix of numbers to parse, so
there is no need to explicitly call this method.
radix - the number base to use for long conversion.public static void resetRadix()
KeyboardUtils already deal with the radix of numbers to parse, so there is no need to explicitly call this method.
setRadix(int)public static LongValidator getInstance()
public java.lang.Long 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.Long 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 | |||||||||