Class DefaultLocalizedFieldMapper
java.lang.Object
ch.tocco.nice2.model.entity.impl.entity.DefaultLocalizedFieldMapper
- All Implemented Interfaces:
LocalizedFieldMapper, LocalizedFieldNamingStrategy
Current impl used for making localized field names.
It appends the language to the field except for the default language. Thus if the availabe languages are "de", "en", "fr" and the default is "de" then a field with the base name "foo" will be created as "foo", "foo_en" and "foo_fr".
The field name mapping strategy may be "overriden" from another module by contributing
an own implementation of LocalizedFieldNamingStrategy. Only one such contribution
is allowed. If none is contributed, the default one is used.
DefaultLocalizedFieldMapper-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFieldName(String name, @Nullable String language) Makes a field name for the given base field name plus the locale.getFieldName(String name, @Nullable Locale locale) String[]getFieldnameParts(String localizedFieldname) The inverse function ofLocalizedFieldNamingStrategy.getFieldName(String, String), that returns the parts of the specified localized field name, that is the original field name and the language.String[]Returns the system-configured languages as 2-letter iso codes in lower case.Returns the system-configured default language, is also present in getNiceLanguages().voidsetFieldMappers(List<LocalizedFieldNamingStrategy> fieldMappers)
-
Constructor Details
-
DefaultLocalizedFieldMapper
-
-
Method Details
-
setFieldMappers
-
getFieldName
Description copied from interface:LocalizedFieldNamingStrategyMakes a field name for the given base field name plus the locale.Possible example:
getFieldName("some_field","fr")→ "some_field_fr"- Specified by:
getFieldNamein interfaceLocalizedFieldNamingStrategy- Parameters:
name- The base field name.language- 2-letter iso code in lower case eg 'fr'.
-
getFieldName
- Specified by:
getFieldNamein interfaceLocalizedFieldNamingStrategy
-
getFieldnameParts
Description copied from interface:LocalizedFieldNamingStrategyThe inverse function ofLocalizedFieldNamingStrategy.getFieldName(String, String), that returns the parts of the specified localized field name, that is the original field name and the language.- Specified by:
getFieldnamePartsin interfaceLocalizedFieldNamingStrategy- Parameters:
localizedFieldname- the localized fieldname- Returns:
- [0] = orginal field name, [1] = language; or
nullif the specified field name could not be recognized as localized
-
getNiceDefaultLanguage
Description copied from interface:LocalizedFieldMapperReturns the system-configured default language, is also present in getNiceLanguages().- Specified by:
getNiceDefaultLanguagein interfaceLocalizedFieldMapper- Returns:
- 2-letter iso code in lower case, eg "fr".
-
getLocales
Description copied from interface:LocalizedFieldMapperReturns the system-configured languages as 2-letter iso codes in lower case.- Specified by:
getLocalesin interfaceLocalizedFieldMapper- Returns:
- Defensive copy, contains at least one entry.
-