Package org.apache.tapestry5.services
Interface TranslatorSource
-
- All Known Implementing Classes:
TranslatorSourceImpl
, value=Translator.class) public interface TranslatorSource
A source forTranslator
s, either by name or by property type. The source knows about two sets of translators: the standard translators contributed directly to the service and the alternate translators, contributed to theTranslatorAlternatesSource
service. Each contributed translator must have a unique name. Generally, Translators are matched by type (i.e., the type matching a particular property that will be read or updated). Contributions to this service use aStrategyRegistry
to match by type. Translators can also be selected by name. TheTranslatorAlternatesSource
service configuration is often used for this purpose. The contribution key must match the translator type.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Translator
valueType)
Finds aTranslator
that is appropriate to the given type, which is usually obtained viaBinding.getBindingType()
.Translator
name)
Returns the translator with the given name (either a standard translator, or an alternate).Translator
valueType)
Finds aTranslator
that is appropriate to the given type, which is usually obtained viaBinding.getBindingType()
.
-
-
-
Method Detail
-
get
name)
Returns the translator with the given name (either a standard translator, or an alternate).- Parameters:
name
- name of translator (as configured, but case is ignored)- Returns:
- the shared translator instance
- Throws:
- if no translator is configured for the provided name
-
findByType
valueType)
Finds aTranslator
that is appropriate to the given type, which is usually obtained viaBinding.getBindingType()
. Performs an inheritance-based search for the best match, among the standard translator (not alternates).- Parameters:
valueType
- the type of value for which a default translator is needed- Returns:
- the matching translator, or null if no match can be found
-
getByType
valueType)
Finds aTranslator
that is appropriate to the given type, which is usually obtained viaBinding.getBindingType()
. Performs an inheritance-based search for the best match, among the standard translators (not alternates).- Parameters:
valueType
- the type of value for which a default translator is needed- Returns:
- the matching translator
- Throws:
- if no standard validator matches the provided type
-
-