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 Summary
Modifier and TypeFieldDescriptionprotected ExtendedEntities
static final String
Prefix defining that the string is actually a key in a localized messages pack.protected List<MessageResolver>
protected Messages
protected Metadata
protected MetadataTools
protected CoreProperties
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns locales set in thejmix.core.available-locales
property as a map of the locale display name to the locale object.getDefaultDateFormat
(javax.persistence.TemporalType temporalType) Returns the first locale from the list defined injmix.core.available-locales
app 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 String
getNotNullMessage
(MetaProperty metaProperty) Get default required message for specified property of MetaClass if it hasNotNull
annotation.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.boolean
isMessageKey
(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
-
MARK
Prefix defining that the string is actually a key in a localized messages pack.- See Also:
-
messages
-
metadata
-
metadataTools
-
extendedEntities
-
properties
-
messageResolvers
-
-
Constructor Details
-
MessageTools
public MessageTools()
-
-
Method Details
-
loadString
Get 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://
-
loadString
Get 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://
-
loadString
Get localized message by reference provided in full or brief format.- Parameters:
group
- message group to use if the second parameter is in brief formatref
- 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://
-
loadString
Get localized message by reference provided in full or brief format.- Parameters:
group
- message group to use if the second parameter is in brief formatref
- 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
-
getPropertyCaption
Get localized name of an entity property.- Parameters:
metaClass
- MetaClass containing the propertypropertyName
- property's name- Returns:
- localized name
-
getPropertyCaption
Get localized name of an entity property.- Parameters:
metaClass
- MetaClass containing the propertypropertyName
- property's namelocale
- locale, if value is null locale of current user is used- Returns:
- localized name
-
getPropertyCaption
Get localized name of an entity property.- Parameters:
property
- MetaProperty- Returns:
- localized name
-
getPropertyCaption
Get localized name of an entity property. Messages pack must be located in the same package as entity.- Parameters:
property
- MetaPropertylocale
- locale, if value is null locale of current user is used- Returns:
- localized name
-
getDefaultRequiredMessage
Get default required message for specified property of MetaClass.- Parameters:
metaClass
- MetaClass containing the propertypropertyName
- property's name- Returns:
- default required message for specified property of MetaClass
-
getNotNullMessage
Get default required message for specified property of MetaClass if it hasNotNull
annotation.- Parameters:
metaProperty
- MetaProperty- Returns:
- localized not null message
-
getMessageRef
Get message reference of an entity property. Messages pack part of the reference corresponds to the entity's package.- Parameters:
metaClass
- MetaClass containing the propertypropertyName
- property's name- Returns:
- message key in the form
msg://message_pack/message_id
-
getMessageRef
Get 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
-
getDefaultLocale
Returns the first locale from the list defined injmix.core.available-locales
app property. -
getLocaleDisplayName
Returns display name of the given locale set in the message bundle with thelocaleDisplayName.<code>
key. If such message is not defined, returnsLocale.getDisplayName()
. -
getAvailableLocalesMap
Returns locales set in thejmix.core.available-locales
property 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
-