Interface NumericTranslatorSupport
- All Known Implementing Classes:
NumericTranslatorSupportImpl
public interface NumericTranslatorSupport
Used to generate the client-side JSON specification for how a number-based validator operates. Uses
ThreadLocale to determine the locale for any locale-specific operations.- Since:
- 5.1.0.1
-
Method Summary
Modifier and TypeMethodDescriptiongetMessageKey(Class<T> type) Returns the default message key for parse failures for the indicated type.<T extends Number>
TparseClient(Class<T> type, String clientValue) Parses a client-submitted value in a localized manner.<T extends Number>
voidsetupTranslation(Class<T> type, Element element, String message) Adds client-side format validation for the field, appropriate to the indicated type.Converts a server-side value to a client-side string.
-
Method Details
-
parseClient
Parses a client-submitted value in a localized manner.- Type Parameters:
T-- Parameters:
type- desired type of valueclientValue- value from client; this will be trimmed of leading/trailing whitespace- Returns:
- the parsed value
- Throws:
ParseException- See Also:
-
toClient
Converts a server-side value to a client-side string. Integer types are formatted simply; decimal types may be formatted using thousands-seperator commas.- Type Parameters:
T-- Parameters:
type- type of value to convertvalue- current (non-null) value- Returns:
- value formatted
-
getMessageKey
Returns the default message key for parse failures for the indicated type.- Type Parameters:
T-- Parameters:
type-- Returns:
- a message key: either "integer-format-exception" or "number-format-exception"
-
setupTranslation
Adds client-side format validation for the field, appropriate to the indicated type.- Parameters:
type- value typeelement-message- message if the client-side value can't be parsed as a number
-