Package io.jmix.core
Class MessageTools
java.lang.Object
io.jmix.core.MessageTools
Utility class to provide common functionality related to localized messages.
 
Implemented as Spring bean to allow extension in application projects.
Implemented as Spring bean to allow extension in application projects.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ExtendedEntitiesstatic final StringPrefix defining that the string is actually a key in a localized messages pack.protected List<MessageResolver>protected Messagesprotected Metadataprotected MetadataToolsprotected CoreProperties
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns locales set in thejmix.core.available-localesproperty as a map of the locale display name to the locale object.getDefaultDateFormat(jakarta.persistence.TemporalType temporalType) Returns the first locale from the list defined injmix.core.available-localesapp property.getDefaultRequiredMessage(MetaClass metaClass, String propertyName) Get default required message for specified property of MetaClass.getDetailedEntityCaption(MetaClass metaClass) getDetailedEntityCaption(MetaClass metaClass, Locale locale) getEntityCaption(MetaClass metaClass) getEntityCaption(MetaClass metaClass, Locale locale) getLocaleDisplayName(Locale locale) Returns display name of the given locale set in the message bundle with thelocaleDisplayName.<code>key.getMessageRef(MetaClass metaClass, String propertyName) Get message reference of an entity property.getMessageRef(MetaProperty property) Get message reference of an entity property.protected StringgetNotNullMessage(MetaProperty metaProperty) Get default required message for specified property of MetaClass if it hasNotNullannotation.getPropertyCaption(MetaClass metaClass, String propertyName) Get localized name of an entity property.getPropertyCaption(MetaClass metaClass, String propertyName, Locale locale) Get localized name of an entity property.getPropertyCaption(MetaProperty property) Get localized name of an entity property.getPropertyCaption(MetaProperty property, Locale locale) Get localized name of an entity property.booleanisMessageKey(String message) loadString(String ref) Get localized message by reference provided in the full format.loadString(String group, String ref) Get localized message by reference provided in full or brief format.loadString(String group, String ref, Locale locale) Get localized message by reference provided in full or brief format.loadString(String ref, Locale locale) Get localized message by reference provided in the full format.
- 
Field Details- 
MARKPrefix defining that the string is actually a key in a localized messages pack.- See Also:
 
- 
messages
- 
metadata
- 
metadataTools
- 
extendedEntities
- 
properties
- 
messageResolvers
 
- 
- 
Constructor Details- 
MessageToolspublic MessageTools()
 
- 
- 
Method Details- 
loadStringGet localized message by reference provided in the full format.- Parameters:
- ref- reference to message in the following format:- msg://group/message_id
- Returns:
- localized message or input string itself if it doesn't begin with msg://
 
- 
loadStringGet localized message by reference provided in the full format.- Parameters:
- ref- reference to message in the following format:- msg://group/message_id
- Returns:
- localized message or input string itself if it doesn't begin with msg://
 
- 
loadStringGet localized message by reference provided in full or brief format.- Parameters:
- group- message group to use if the second parameter is in brief format
- ref- reference to message in the following format:- Full: msg://group/message_id
- Brief: msg://message_id, in this case the first parameter is taken into account
 
- Full: 
- Returns:
- localized message or input string itself if it doesn't begin with msg://
 
- 
loadStringGet localized message by reference provided in full or brief format.- Parameters:
- group- message group to use if the second parameter is in brief format
- ref- reference to message in the following format:
- locale- locale- Full: msg://group/message_id
- Brief: msg://message_id, in this case the first parameter is taken into account
 
- Full: 
- Returns:
- localized message or input string itself if it doesn't begin with msg://
 
- 
getEntityCaption- Returns:
- a localized name of an entity. Messages pack must be located in the same package as entity.
 
- 
getEntityCaption- Returns:
- a localized name of an entity with given locale or default if null
 
- 
getDetailedEntityCaption- Returns:
- a detailed localized name of an entity
 
- 
getDetailedEntityCaption- Returns:
- a detailed localized name of an entity with given locale or default if null
 
- 
getPropertyCaptionGet localized name of an entity property.- Parameters:
- metaClass- MetaClass containing the property
- propertyName- property's name
- Returns:
- localized name
 
- 
getPropertyCaptionGet localized name of an entity property.- Parameters:
- metaClass- MetaClass containing the property
- propertyName- property's name
- locale- locale, if value is null locale of current user is used
- Returns:
- localized name
 
- 
getPropertyCaptionGet localized name of an entity property.- Parameters:
- property- MetaProperty
- Returns:
- localized name
 
- 
getPropertyCaptionGet localized name of an entity property. Messages pack must be located in the same package as entity.- Parameters:
- property- MetaProperty
- locale- locale, if value is null locale of current user is used
- Returns:
- localized name
 
- 
getDefaultRequiredMessageGet default required message for specified property of MetaClass.- Parameters:
- metaClass- MetaClass containing the property
- propertyName- property's name
- Returns:
- default required message for specified property of MetaClass
 
- 
getNotNullMessageGet default required message for specified property of MetaClass if it hasNotNullannotation.- Parameters:
- metaProperty- MetaProperty
- Returns:
- localized not null message
 
- 
getMessageRefGet message reference of an entity property. Messages pack part of the reference corresponds to the entity's package.- Parameters:
- metaClass- MetaClass containing the property
- propertyName- property's name
- Returns:
- message key in the form msg://message_pack/message_id
 
- 
getMessageRefGet message reference of an entity property. Messages pack part of the reference corresponds to the entity's package.- Parameters:
- property- MetaProperty
- Returns:
- message key in the form msg://message_pack/message_id
 
- 
getDefaultLocaleReturns the first locale from the list defined injmix.core.available-localesapp property.
- 
getLocaleDisplayNameReturns display name of the given locale set in the message bundle with thelocaleDisplayName.<code>key. If such message is not defined, returnsLocale.getDisplayName().
- 
getAvailableLocalesMapReturns locales set in thejmix.core.available-localesproperty as a map of the locale display name to the locale object.
- 
getDefaultDateFormat- Parameters:
- temporalType- a temporal type
- Returns:
- default date format string for passed temporal type
 
- 
isMessageKey- Parameters:
- message- a message to check
- Returns:
- whether the given message is a key in a localized messages pack
 
 
-