@Component(value="cuba_MessageTools")
public class MessageTools
extends java.lang.Object
Messages.getTools() method.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MAIN_MARK |
static java.lang.String |
MARK
Prefix defining that the string is actually a key in a localized messages pack.
|
static java.lang.String |
NAME |
| Constructor and Description |
|---|
MessageTools(Configuration configuration) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDefaultDateFormat(javax.persistence.TemporalType temporalType) |
java.util.Locale |
getDefaultLocale() |
java.lang.String |
getDefaultRequiredMessage(MetaClass metaClass,
java.lang.String propertyName)
Get default required message for specified property of MetaClass.
|
java.lang.String |
getDefaultRequiredMessage(MetaProperty metaProperty)
Deprecated.
|
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 |
getLocValue(java.lang.String attribute,
Instance instance)
Get localized value of an attribute based on
LocalizedValue annotation. |
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.
|
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 |
hasPropertyCaption(MetaProperty property)
Checks whether a localized name of the property exists.
|
java.lang.String |
inferMessagePack(java.lang.String attribute,
Instance instance)
Returns message pack inferred from
LocalizedValue annotation. |
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 messagesPack,
java.lang.String ref)
Get localized message by reference provided in full or brief format.
|
java.lang.String |
loadString(java.lang.String messagesPack,
java.lang.String ref,
java.util.Locale locale)
Get localized message by reference provided in full or brief format.
|
java.lang.String |
localeToString(java.util.Locale locale)
Locale representation depending on
cuba.useLocaleLanguageOnly application property. |
java.util.Locale |
trimLocale(java.util.Locale locale)
Trims locale to language-only if
useLocaleLanguageOnly() is true. |
boolean |
useLocaleLanguageOnly() |
public static final java.lang.String MARK
public static final java.lang.String MAIN_MARK
public static final java.lang.String NAME
@Inject public MessageTools(Configuration configuration)
public java.lang.String loadString(java.lang.String ref)
ref - reference to message in the following format: msg://message_pack/message_idmsg://public java.lang.String loadString(java.lang.String ref,
java.util.Locale locale)
ref - reference to message in the following format: msg://message_pack/message_idmsg://@Nullable
public java.lang.String loadString(@Nullable
java.lang.String messagesPack,
@Nullable
java.lang.String ref)
messagesPack - messages pack to use if the second parameter is in brief formatref - reference to message in the following format:
msg://message_pack/message_id
msg://message_id, in this case the first parameter is taken into account
mainMsg://message_id
msg:// or mainMsg://@Nullable
public java.lang.String loadString(@Nullable
java.lang.String messagesPack,
@Nullable
java.lang.String ref,
@Nullable
java.util.Locale locale)
messagesPack - messages pack to use if the second parameter is in brief formatref - reference to message in the following format:locale - locale
msg://message_pack/message_id
msg://message_id, in this case the first parameter is taken into account
mainMsg://message_id
msg:// or mainMsg://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 boolean hasPropertyCaption(MetaProperty property)
property - MetaPropertygetPropertyCaption(com.haulmont.chile.core.model.MetaProperty) returns a
string which has no dots inside or the first part before a dot is not equal to the declaring class@Deprecated public java.lang.String getDefaultRequiredMessage(MetaProperty metaProperty)
getDefaultRequiredMessage(MetaClass, String)public java.lang.String getDefaultRequiredMessage(MetaClass metaClass, java.lang.String propertyName)
metaClass - MetaClass containing the propertypropertyName - property's namepublic java.lang.String getMessageRef(MetaClass metaClass, java.lang.String propertyName)
metaClass - MetaClass containing the propertypropertyName - property's namemsg://message_pack/message_idpublic java.lang.String getMessageRef(MetaProperty property)
property - MetaPropertymsg://message_pack/message_id@Nullable
public java.lang.String getLocValue(java.lang.String attribute,
Instance instance)
LocalizedValue annotation.attribute - attribute nameinstance - entity instance@Nullable
public java.lang.String inferMessagePack(java.lang.String attribute,
Instance instance)
LocalizedValue annotation.attribute - attribute nameinstance - entity instancepublic boolean useLocaleLanguageOnly()
cuba.availableLocales app property are language only.public java.lang.String localeToString(java.util.Locale locale)
cuba.useLocaleLanguageOnly application property.locale - locale instancecuba.useLocaleLanguageOnly=true, or full locale representation otherwisepublic java.util.Locale trimLocale(java.util.Locale locale)
useLocaleLanguageOnly() is true.locale - a localepublic java.util.Locale getDefaultLocale()
cuba.availableLocales app property, taking into
account useLocaleLanguageOnly() return value.public java.lang.String getDefaultDateFormat(javax.persistence.TemporalType temporalType)
temporalType - a temporal type