org.apache.tapestry5.internal.translator
Class NumericTranslatorSupportImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.translator.NumericTranslatorSupportImpl
All Implemented Interfaces:
NumericTranslatorSupport

public class NumericTranslatorSupportImpl
extends Object
implements NumericTranslatorSupport


Constructor Summary
NumericTranslatorSupportImpl(TypeCoercer typeCoercer, ThreadLocale threadLocale, Request request, JavaScriptSupport javascriptSupport, ClientBehaviorSupport clientBehaviorSupport, boolean compactJSON)
           
 
Method Summary
<T extends Number>
void
addValidation(Class<T> type, Field field, String message)
          Adds client-side format validation for the field, appropriate to the indicated type.
<T extends Number>
String
getMessageKey(Class<T> type)
          Returns the default message key for parse failures for the indicated type.
<T extends Number>
T
parseClient(Class<T> type, String clientValue)
          Parses a client-submitted value in a localized manner.
<T extends Number>
String
toClient(Class<T> type, T value)
          Converts a server-side value to a client-side string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericTranslatorSupportImpl

public NumericTranslatorSupportImpl(TypeCoercer typeCoercer,
                                    ThreadLocale threadLocale,
                                    Request request,
                                    JavaScriptSupport javascriptSupport,
                                    ClientBehaviorSupport clientBehaviorSupport,
                                    @Symbol(value="tapestry.compact-json")
                                    boolean compactJSON)
Method Detail

addValidation

public <T extends Number> void addValidation(Class<T> type,
                                             Field field,
                                             String message)
Description copied from interface: NumericTranslatorSupport
Adds client-side format validation for the field, appropriate to the indicated type.

Specified by:
addValidation in interface NumericTranslatorSupport
Parameters:
type - value type
field - field to which validation should be added
message - message if the client-side value can't be parsed as a number

parseClient

public <T extends Number> T parseClient(Class<T> type,
                                        String clientValue)
                             throws ParseException
Description copied from interface: NumericTranslatorSupport
Parses a client-submitted value in a localized manner.

Specified by:
parseClient in interface NumericTranslatorSupport
Parameters:
type - desired type of value
clientValue - value from client; this will be trimmed of leading/trailing whitespace
Returns:
the parsed value
Throws:
ParseException
See Also:
Translator.parseClient(org.apache.tapestry5.Field, String, String)

toClient

public <T extends Number> String toClient(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 interface NumericTranslatorSupport
Parameters:
type - type of value to convert
value - current (non-null) value
Returns:
value formatted

getMessageKey

public <T extends Number> String getMessageKey(Class<T> type)
Description copied from interface: NumericTranslatorSupport
Returns the default message key for parse failures for the indicated type.

Specified by:
getMessageKey in interface NumericTranslatorSupport
Returns:
a message key: either "integer-format-exception" or "number-format-exception"


Copyright © 2003-2012 The Apache Software Foundation.