org.apache.tapestry
Interface Translator<T>

Type Parameters:
T -
All Known Implementing Classes:
ByteTranslator, DoubleTranslator, FloatTranslator, IntegerTranslator, LongTranslator, StringTranslator

public interface Translator<T>

Translates between client-side and server-side values. Client-side values are always strings.

See Also:
org.apache.tapestry.services.TranslatorDefaultSource, FieldValidationSupport

Method Summary
 Class<T> getType()
          Returns the type of the server-side value.
 T parseClient(String clientValue, Messages messages)
          Converts a submitted request value into an appropriate server side value.
 String toClient(T value)
          Converts a server-side value to a client-side string.
 

Method Detail

toClient

String toClient(T value)
Converts a server-side value to a client-side string. This allows for formatting of the value in a way appropriate to the end user. The output client value should be parsable by parseClient(String, Messages).

Parameters:
value - the server side value (which will not be null)
Returns:
client-side value to present to the user

getType

Class<T> getType()
Returns the type of the server-side value.

Returns:
a type

parseClient

T parseClient(String clientValue,
              Messages messages)
              throws ValidationException
Converts a submitted request value into an appropriate server side value.

Parameters:
clientValue - to convert to a server value; this will not be null, but may be blank
messages - validator messages assembled by ValidationMessagesSource
Returns:
equivalent server-side value (possibly null)
Throws:
ValidationException - if the value can not be parsed


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.