@Component(value="core_MessageTools")
public class MessageTools
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected ExtendedEntities |
extendedEntities |
static java.lang.String |
MARK
Prefix defining that the string is actually a key in a localized messages pack.
|
protected java.util.List<MessageResolver> |
messageResolvers |
protected Messages |
messages |
protected Metadata |
metadata |
protected MetadataTools |
metadataTools |
protected CoreProperties |
properties |
Constructor and Description |
---|
MessageTools() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.util.Locale> |
getAvailableLocalesMap()
Returns locales set in the
jmix.core.available-locales property as a map of the locale display name
to the locale object. |
java.lang.String |
getDefaultDateFormat(javax.persistence.TemporalType temporalType) |
java.util.Locale |
getDefaultLocale()
Returns the first locale from the list defined in
jmix.core.available-locales app property. |
java.lang.String |
getDefaultRequiredMessage(MetaClass metaClass,
java.lang.String propertyName)
Get default required message for specified property of MetaClass.
|
java.lang.String |
getDetailedEntityCaption(MetaClass metaClass) |
java.lang.String |
getDetailedEntityCaption(MetaClass metaClass,
java.util.Locale locale) |
java.lang.String |
getEntityCaption(MetaClass metaClass) |
java.lang.String |
getEntityCaption(MetaClass metaClass,
java.util.Locale locale) |
java.lang.String |
getLocaleDisplayName(java.util.Locale locale)
Returns display name of the given locale set in the message bundle with the
localeDisplayName.<code> key. |
java.lang.String |
getMessageRef(MetaClass metaClass,
java.lang.String propertyName)
Get message reference of an entity property.
|
java.lang.String |
getMessageRef(MetaProperty property)
Get message reference of an entity property.
|
protected java.lang.String |
getNotNullMessage(MetaProperty metaProperty)
Get default required message for specified property of MetaClass if it has
NotNull annotation. |
java.lang.String |
getPropertyCaption(MetaClass metaClass,
java.lang.String propertyName)
Get localized name of an entity property.
|
java.lang.String |
getPropertyCaption(MetaClass metaClass,
java.lang.String propertyName,
java.util.Locale locale)
Get localized name of an entity property.
|
java.lang.String |
getPropertyCaption(MetaProperty property)
Get localized name of an entity property.
|
java.lang.String |
getPropertyCaption(MetaProperty property,
java.util.Locale locale)
Get localized name of an entity property.
|
boolean |
isMessageKey(java.lang.String message) |
java.lang.String |
loadString(java.lang.String ref)
Get localized message by reference provided in the full format.
|
java.lang.String |
loadString(java.lang.String ref,
java.util.Locale locale)
Get localized message by reference provided in the full format.
|
java.lang.String |
loadString(java.lang.String group,
java.lang.String ref)
Get localized message by reference provided in full or brief format.
|
java.lang.String |
loadString(java.lang.String group,
java.lang.String ref,
java.util.Locale locale)
Get localized message by reference provided in full or brief format.
|
public static final java.lang.String MARK
@Autowired protected Messages messages
@Autowired protected Metadata metadata
@Autowired protected MetadataTools metadataTools
@Autowired protected ExtendedEntities extendedEntities
@Autowired protected CoreProperties properties
@Autowired(required=false) protected java.util.List<MessageResolver> messageResolvers
public java.lang.String loadString(@Nullable java.lang.String ref)
ref
- reference to message in the following format: msg://group/message_id
msg://
public java.lang.String loadString(java.lang.String ref, java.util.Locale locale)
ref
- reference to message in the following format: msg://group/message_id
msg://
public java.lang.String loadString(@Nullable java.lang.String group, @Nullable java.lang.String ref)
group
- message group to use if the second parameter is in brief formatref
- reference to message in the following format:
msg://group/message_id
msg://message_id
, in this case the first parameter is taken into account
msg://
public java.lang.String loadString(@Nullable java.lang.String group, @Nullable java.lang.String ref, @Nullable java.util.Locale locale)
group
- message group to use if the second parameter is in brief formatref
- reference to message in the following format:locale
- locale
msg://group/message_id
msg://message_id
, in this case the first parameter is taken into account
msg://
public java.lang.String getEntityCaption(MetaClass metaClass)
public java.lang.String getEntityCaption(MetaClass metaClass, @Nullable java.util.Locale locale)
public java.lang.String getDetailedEntityCaption(MetaClass metaClass)
public java.lang.String getDetailedEntityCaption(MetaClass metaClass, @Nullable java.util.Locale locale)
public java.lang.String getPropertyCaption(MetaClass metaClass, java.lang.String propertyName)
metaClass
- MetaClass containing the propertypropertyName
- property's namepublic java.lang.String getPropertyCaption(MetaClass metaClass, java.lang.String propertyName, @Nullable java.util.Locale locale)
metaClass
- MetaClass containing the propertypropertyName
- property's namelocale
- locale, if value is null locale of current user is usedpublic java.lang.String getPropertyCaption(MetaProperty property)
property
- MetaPropertypublic java.lang.String getPropertyCaption(MetaProperty property, @Nullable java.util.Locale locale)
property
- MetaPropertylocale
- locale, if value is null locale of current user is usedpublic java.lang.String getDefaultRequiredMessage(MetaClass metaClass, java.lang.String propertyName)
metaClass
- MetaClass containing the propertypropertyName
- property's name@Nullable protected java.lang.String getNotNullMessage(MetaProperty metaProperty)
NotNull
annotation.metaProperty
- MetaPropertypublic java.lang.String getMessageRef(MetaClass metaClass, java.lang.String propertyName)
metaClass
- MetaClass containing the propertypropertyName
- property's namemsg://message_pack/message_id
public java.lang.String getMessageRef(MetaProperty property)
property
- MetaPropertymsg://message_pack/message_id
public java.util.Locale getDefaultLocale()
jmix.core.available-locales
app property.public java.lang.String getLocaleDisplayName(java.util.Locale locale)
localeDisplayName.<code>
key.
If such message is not defined, returns Locale.getDisplayName()
.public java.util.Map<java.lang.String,java.util.Locale> getAvailableLocalesMap()
jmix.core.available-locales
property as a map of the locale display name
to the locale object.public java.lang.String getDefaultDateFormat(@Nullable javax.persistence.TemporalType temporalType)
temporalType
- a temporal typepublic boolean isMessageKey(@Nullable java.lang.String message)
message
- a message to check