Package org.silverpeas.core.i18n
Class AbstractI18NBean<T extends BeanTranslation>
- java.lang.Object
-
- org.silverpeas.core.i18n.AbstractI18NBean<T>
-
- All Implemented Interfaces:
Serializable
,I18NBean<T>
,Translatable
,Nameable
- Direct Known Subclasses:
AbstractBean
,AxisHeader
,ComponentInst
,ComponentInstLight
,GlobalSilverContent
,NodeDetail
,PublicationDetail
,SilverContent
,SpaceInst
,SpaceInstLight
,TreeNode
public abstract class AbstractI18NBean<T extends BeanTranslation> extends Object implements Serializable, Nameable, I18NBean<T>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractI18NBean()
protected
AbstractI18NBean(AbstractI18NBean<T> other)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addTranslation(T translation)
Map<String,T>
getClonedTranslations()
Gets cloned translations.
This is useful on copy/paste operations.String
getDescription()
Gets the description about the bean in the language defined by thegetLanguage()
property.String
getDescription(String language)
Gets the description about the bean in the given language.String
getLanguage()
Collection<String>
getLanguages()
String
getLanguageToDisplay(String language)
String
getName()
Gets the name of the bean in the language defined by thegetLanguage()
property.String
getName(String language)
Gets the name of the bean in the given language.T
getNextTranslation()
Browses the different supported languages for a translation.T
getTranslation(String language)
Gets a possible translation for the specified language.String
getTranslationId()
Map<String,T>
getTranslations()
Gets all the actually translations handled by this bean.protected abstract Class<T>
getTranslationType()
boolean
isRemoveTranslation()
void
setDescription(String description)
Gets the description about the bean in the language defined by thegetLanguage()
property.void
setLanguage(String language)
Sets the language in which the default values of the textual properties of the bean are set.void
setName(String name)
Sets the name of the bean in the language defined by thegetLanguage()
property.void
setRemoveTranslation(boolean removeTranslation)
void
setTranslationId(String translationId)
Sets a unique identifier for the translation by default of the bean (the default values of the textual properties of the bean).void
setTranslations(Collection<T> translations)
void
setTranslations(Map<String,T> translations)
-
-
-
Constructor Detail
-
AbstractI18NBean
protected AbstractI18NBean()
-
AbstractI18NBean
protected AbstractI18NBean(AbstractI18NBean<T> other)
-
-
Method Detail
-
getName
public String getName()
Gets the name of the bean in the language defined by thegetLanguage()
property.
-
setName
public void setName(String name)
Sets the name of the bean in the language defined by thegetLanguage()
property.- Parameters:
name
- the name of the bean.
-
getDescription
public final String getDescription()
Gets the description about the bean in the language defined by thegetLanguage()
property.- Specified by:
getDescription
in interfaceNameable
- Returns:
- a short description about the bean.
-
setDescription
public final void setDescription(String description)
Gets the description about the bean in the language defined by thegetLanguage()
property.- Parameters:
description
- a short description about the bean.
-
getName
public String getName(String language)
Gets the name of the bean in the given language. This method is a shortcut of the following code:myBean.getTranslation(language).getName();
- Parameters:
language
- the ISO 631-1 code of the language- Returns:
- the name of the bean in the specified language.
-
getDescription
public String getDescription(String language)
Gets the description about the bean in the given language. This method is a shortcut of the following code:myBean.getTranslation(language).getDescription();
- Parameters:
language
- the ISO 631-1 code of the language- Returns:
- the description about the bean in the specified language.
-
getLanguage
public String getLanguage()
-
setLanguage
public void setLanguage(String language)
Description copied from interface:I18NBean
Sets the language in which the default values of the textual properties of the bean are set. By default, the language of those values are in the language defined by theI18n.getDefaultLanguage()
method- Specified by:
setLanguage
in interfaceI18NBean<T extends BeanTranslation>
- Parameters:
language
- the language.
-
isRemoveTranslation
public boolean isRemoveTranslation()
-
setRemoveTranslation
public void setRemoveTranslation(boolean removeTranslation)
- Specified by:
setRemoveTranslation
in interfaceI18NBean<T extends BeanTranslation>
-
getTranslationId
public String getTranslationId()
-
setTranslationId
public void setTranslationId(String translationId)
Description copied from interface:I18NBean
Sets a unique identifier for the translation by default of the bean (the default values of the textual properties of the bean).- Specified by:
setTranslationId
in interfaceI18NBean<T extends BeanTranslation>
- Parameters:
translationId
- a unique identifier of the default translation.
-
getLanguages
public Collection<String> getLanguages()
-
getTranslations
public Map<String,T> getTranslations()
Description copied from interface:I18NBean
Gets all the actually translations handled by this bean.- Specified by:
getTranslations
in interfaceI18NBean<T extends BeanTranslation>
- Returns:
- a map with as key the ISO 631-1 code of a language and as value the translation in that language.
-
getClonedTranslations
public Map<String,T> getClonedTranslations()
Gets cloned translations.
This is useful on copy/paste operations.- Returns:
- a clone of
getTranslations()
result.
-
setTranslations
public void setTranslations(Collection<T> translations)
-
getTranslation
public T getTranslation(String language)
Gets a possible translation for the specified language. If no such translation exists in the given language then browse for a language for which a translation exists. This method will return always a translation; indeed in the case there is no translation in whatever supported language, then a default translation with the actual bean's properties is returned.- Specified by:
getTranslation
in interfaceTranslatable
- Parameters:
language
- the ISO 631-1 code of the language.- Returns:
- a translation. Never null.
-
addTranslation
public void addTranslation(T translation)
-
getNextTranslation
public T getNextTranslation()
Description copied from interface:I18NBean
Browses the different supported languages for a translation. The browsing starts with the default language as defined by the propertyI18n.getDefaultLanguage()
.- Specified by:
getNextTranslation
in interfaceI18NBean<T extends BeanTranslation>
- Returns:
- a translation.
-
-