Class NumericTranslatorSupportImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.translator.NumericTranslatorSupportImpl
-
- All Implemented Interfaces:
NumericTranslatorSupport
public class NumericTranslatorSupportImpl extends java.lang.Object implements NumericTranslatorSupport
-
-
Constructor Summary
Constructors Constructor Description NumericTranslatorSupportImpl(TypeCoercer typeCoercer, ThreadLocale threadLocale, JavaScriptSupport javascriptSupport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.Number>
java.lang.StringgetMessageKey(java.lang.Class<T> type)
Returns the default message key for parse failures for the indicated type.<T extends java.lang.Number>
TparseClient(java.lang.Class<T> type, java.lang.String clientValue)
Parses a client-submitted value in a localized manner.<T extends java.lang.Number>
voidsetupTranslation(java.lang.Class<T> type, Element element, java.lang.String message)
Adds client-side format validation for the field, appropriate to the indicated type.<T extends java.lang.Number>
java.lang.StringtoClient(java.lang.Class<T> type, T value)
Converts a server-side value to a client-side string.
-
-
-
Constructor Detail
-
NumericTranslatorSupportImpl
public NumericTranslatorSupportImpl(TypeCoercer typeCoercer, ThreadLocale threadLocale, JavaScriptSupport javascriptSupport)
-
-
Method Detail
-
setupTranslation
public <T extends java.lang.Number> void setupTranslation(java.lang.Class<T> type, Element element, java.lang.String message)
Description copied from interface:NumericTranslatorSupport
Adds client-side format validation for the field, appropriate to the indicated type.- Specified by:
setupTranslation
in interfaceNumericTranslatorSupport
- Parameters:
type
- value typemessage
- message if the client-side value can't be parsed as a number
-
parseClient
public <T extends java.lang.Number> T parseClient(java.lang.Class<T> type, java.lang.String clientValue) throws java.text.ParseException
Description copied from interface:NumericTranslatorSupport
Parses a client-submitted value in a localized manner.- Specified by:
parseClient
in interfaceNumericTranslatorSupport
- Parameters:
type
- desired type of valueclientValue
- value from client; this will be trimmed of leading/trailing whitespace- Returns:
- the parsed value
- Throws:
java.text.ParseException
- See Also:
Translator.parseClient(org.apache.tapestry5.Field, String, String)
-
toClient
public <T extends java.lang.Number> java.lang.String toClient(java.lang.Class<T> type, T value)
Description copied from interface:NumericTranslatorSupport
Converts a server-side value to a client-side string. Integer types are formatted simply; decimal types may be formatted using thousands-seperator commas.- Specified by:
toClient
in interfaceNumericTranslatorSupport
- Parameters:
type
- type of value to convertvalue
- current (non-null) value- Returns:
- value formatted
-
getMessageKey
public <T extends java.lang.Number> java.lang.String getMessageKey(java.lang.Class<T> type)
Description copied from interface:NumericTranslatorSupport
Returns the default message key for parse failures for the indicated type.- Specified by:
getMessageKey
in interfaceNumericTranslatorSupport
- Returns:
- a message key: either "integer-format-exception" or "number-format-exception"
-
-