com.fedmest.cw.keyboard.validators
Class ValueTypeValidator<T>
java.lang.Object
com.fedmest.cw.keyboard.validators.ValueTypeValidator<T>
- Type Parameters:
T - the type of data that will be returned after conversion if validation succeeds
- All Implemented Interfaces:
- KeyboardInputValidator<T>
- Direct Known Subclasses:
- BooleanValidator, CharValidator, DoubleValidator, FloatValidator, IntValidator, LongValidator
public abstract class ValueTypeValidator<T>
- extends java.lang.Object
- implements KeyboardInputValidator<T>
Abstract base class for primitive data type input through the keyboard. It defines the behaviour of a set of keyboard input
validators that deal with primitive types. This class deals with the error message feature, handled by a static variable that
applies to all subclasses and defines the message to be displayed on all uses of any validator in this hirerarchy subsequent to
its setting.
- Version:
- 1.0
- Author:
- Federico Mestrone
|
Field Summary |
protected static java.lang.String |
errorMessage
the error message that will be returned as the exception message if validation fails. |
|
Method Summary |
static void |
resetErrorMessage()
This method resets the error message that will be displayed to users on validation failure to the default text
("Invalid value - retry"). |
static void |
setErrorMessage(java.lang.String errorMessage)
This method sets the error message that will be displayed to the user if validation fails. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
errorMessage
protected static java.lang.String errorMessage
- the error message that will be returned as the exception message if validation fails.
- See Also:
setErrorMessage(String),
resetErrorMessage(),
KeyboardInputException
setErrorMessage
public static void setErrorMessage(java.lang.String errorMessage)
- This method sets the error message that will be displayed to the user if validation fails. 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
resetErrorMessage() or changed with this method again.
- Parameters:
errorMessage - the new error message to display to users
resetErrorMessage
public static void resetErrorMessage()
- This method resets the error message that will be displayed to users on validation failure to the default text
("Invalid value - retry").
- See Also:
setErrorMessage(String)
Copyright © 2008 Federico Mestrone. All Rights Reserved.