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().void
setFieldMappers
(List<LocalizedFieldNamingStrategy> fieldMappers)
-
Constructor Details
-
DefaultLocalizedFieldMapper
-
-
Method Details
-
setFieldMappers
-
getFieldName
Description copied from interface:LocalizedFieldNamingStrategy
Makes a field name for the given base field name plus the locale.Possible example:
getFieldName("some_field","fr")
→ "some_field_fr"- Specified by:
getFieldName
in interfaceLocalizedFieldNamingStrategy
- Parameters:
name
- The base field name.language
- 2-letter iso code in lower case eg 'fr'.
-
getFieldName
- Specified by:
getFieldName
in interfaceLocalizedFieldNamingStrategy
-
getFieldnameParts
Description copied from interface:LocalizedFieldNamingStrategy
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.- Specified by:
getFieldnameParts
in interfaceLocalizedFieldNamingStrategy
- Parameters:
localizedFieldname
- the localized fieldname- Returns:
- [0] = orginal field name, [1] = language; or
null
if the specified field name could not be recognized as localized
-
getNiceDefaultLanguage
Description copied from interface:LocalizedFieldMapper
Returns the system-configured default language, is also present in getNiceLanguages().- Specified by:
getNiceDefaultLanguage
in interfaceLocalizedFieldMapper
- Returns:
- 2-letter iso code in lower case, eg "fr".
-
getLocales
Description copied from interface:LocalizedFieldMapper
Returns the system-configured languages as 2-letter iso codes in lower case.- Specified by:
getLocales
in interfaceLocalizedFieldMapper
- Returns:
- Defensive copy, contains at least one entry.
-