Class Message
java.lang.Object
de.hybris.platform.sap.core.common.message.Message
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
OrderMgmtMessage
The Message class helps you to handle messages which can by displayed on the UI or logged in the log file.
To create the message you give the type, the resource key and optional the name of a property.
The message text itself can be defined in to different ways:
- Resource key: The resource key needs to be defined as described in
ModuleResourceAccess. . - Message description: This is best approach if you already have a translated message description e.g. provided from the back end.
getMessageText(Locale) can be used to get the message text in any case.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant to define message type debug.static final intConstant to define message type success.static final intConstant to define message type info.static final intConstant to define initial value.static final intConstant to define message type success.static final intConstant to define message type warning. -
Constructor Summary
ConstructorsConstructorDescriptionMessage(int type) Constructor to create a message with a given type.Constructor to create a message only with resource key.Constructor to create a message with a resource key without args.Constructor to create a message with a resource key. -
Method Summary
Modifier and TypeMethodDescriptionbooleanOverwrites the method of the object class.Gets the description of the message.Gets the field id.Determine the message text for the default locale given withLocale.getDefault().getMessageText(Locale locale) Determines the message text for the given locale.Gets the page location of the message.Gets the position of the message.Gets the name of the property to which the message belongs.Returns the property refTechKey.String[]Returns the property resourceArgs.Returns the property resourceKey.Returns the technical key of the message.intgetType()Returns the type of the message.inthashCode()Returns hash code for the message.booleanisError()Returns if the message is an error message.booleanisInfo()booleanReturns if the message is a warning.voidlog(org.apache.log4j.Logger logger) Logs the message in the given logger.voidsetDescription(String description) Sets the description of the message.voidsetFieldId(String fieldId) Sets the field id.voidsetModuleResourceAccess(ModuleResourceAccess moduleResourceAccess) Sets the module resource access from outside (optional, e.g.voidsetPageLocation(String pagelocation) Sets the page location of the message.voidsetPosition(String position) Sets the position of the message.voidsetProperty(String property) Sets the name of the property to which the message belongs.voidsetRefTechKey(TechKey refTechKey) Sets the property refTechKey.voidsetResourceArgs(String[] resourceArgs) Sets the property resourceArgs.voidsetResourceKey(String resourceKey) Sets the property resourceKey.voidsetTechKey(TechKey techKey) Sets the techKey of the message.toString()Returns the object as string.
-
Field Details
-
INITIAL
public static final int INITIALConstant to define initial value.- See Also:
-
SUCCESS
public static final int SUCCESSConstant to define message type success.- See Also:
-
ERROR
public static final int ERRORConstant to define message type success.- See Also:
-
WARNING
public static final int WARNINGConstant to define message type warning.- See Also:
-
INFO
public static final int INFOConstant to define message type info.- See Also:
-
DEBUG
public static final int DEBUGConstant to define message type debug.- See Also:
-
-
Constructor Details
-
Message
Constructor to create a message with a resource key.- Parameters:
type- message typekey- resource key to the message textargs- an array of arguments.property- name of property of a bean (only if property isn't null)
-
Message
public Message(int type) Constructor to create a message with a given type.- Parameters:
type- message type
-
Message
Constructor to create a message with a resource key without args.- Parameters:
type- message typekey- resource key to the message textproperty- name of property of a bean
-
Message
Constructor to create a message only with resource key.- Parameters:
type- message typekey- resource key to the message text
-
-
Method Details
-
setModuleResourceAccess
Sets the module resource access from outside (optional, e.g. for tests)- Parameters:
moduleResourceAccess- module resource access
-
getMessageText
Determines the message text for the given locale.The method checks first, if the there is a resourceKey is defined. If so, this is used to get a translated message text with the
ModuleResourceAccess. If not, the message description, which is independent from the given locale, is used.- Parameters:
locale- locale to get the correct translation.- Returns:
- the translated message
- See Also:
-
getMessageText
Determine the message text for the default locale given with
Locale.getDefault().For further details take a look at
getMessageText(Locale)- Returns:
- translated message tag
-
getDescription
Gets the description of the message.- Returns:
- description of the message
-
setDescription
Sets the description of the message.- Parameters:
description- Description of the message
-
getPageLocation
Gets the page location of the message.- Returns:
- The page location
-
setPageLocation
Sets the page location of the message.The page location is used in the accessibility mode to describe, where the error occurs. Please define a resource key
access.message.location.for your page locations.- Parameters:
pagelocation- Location where the message occurs
-
getPosition
Gets the position of the message.- Returns:
- return the exact position where the message occurs
-
setPosition
Sets the position of the message.- Parameters:
position- Exact position where the message occurs
-
isError
public boolean isError()Returns if the message is an error message.- Returns:
- true if the message is an error message
-
isWarning
public boolean isWarning()Returns if the message is a warning.- Returns:
- true if the message is a warning
-
isInfo
public boolean isInfo() -
setProperty
Sets the name of the property to which the message belongs.- Parameters:
property- name of the property to which the message belongs (only if property isn't null)
-
getProperty
Gets the name of the property to which the message belongs.- Returns:
- field name of the property to which the message belongs
-
setRefTechKey
Sets the property refTechKey.- Parameters:
refTechKey- techKey for object to which belongs the message. is only for message which can not directly assign to the corresponding business object.
-
getRefTechKey
Returns the property refTechKey.- Returns:
- refTechKey
-
setResourceKey
Sets the property resourceKey.- Parameters:
resourceKey- resource key
-
getResourceKey
Returns the property resourceKey.- Returns:
- resource key
-
setResourceArgs
Sets the property resourceArgs.- Parameters:
resourceArgs- resource key arguments
-
getResourceArgs
Returns the property resourceArgs.- Returns:
- resource key arguments
-
getType
public int getType()Returns the type of the message.- Returns:
- The type of the message
-
equals
Overwrites the method of the object class. -
hashCode
public int hashCode()Returns hash code for the message. -
log
public void log(org.apache.log4j.Logger logger) Logs the message in the given logger.- Parameters:
logger- logger
-
toString
Returns the object as string. -
getTechKey
Returns the technical key of the message. For CRM or ERP messages the technical key consists of the message ID and message number separated by space (e.g. "CRM_ORDER 002").- Returns:
- the techKey
-
setTechKey
Sets the techKey of the message.- Parameters:
techKey- the techKey to set
-
getFieldId
Gets the field id.- Returns:
- field id
-
setFieldId
Sets the field id.- Parameters:
fieldId- field id
-