Class Message

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    OrderMgmtMessage

    public class Message
    extends java.lang.Object
    implements java.io.Serializable
    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.
    The method getMessageText(Locale) can be used to get the message text in any case.

    See Also:
    MessageList, ModuleResourceAccess, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEBUG
      Constant to define message type debug.
      static int ERROR
      Constant to define message type success.
      static int INFO
      Constant to define message type info.
      static int INITIAL
      Constant to define initial value.
      static int SUCCESS
      Constant to define message type success.
      static int WARNING
      Constant to define message type warning.
    • Constructor Summary

      Constructors 
      Constructor Description
      Message​(int type)
      Constructor to create a message with a given type.
      Message​(int type, java.lang.String key)
      Constructor to create a message only with resource key.
      Message​(int type, java.lang.String key, java.lang.String property)
      Constructor to create a message with a resource key without args.
      Message​(int type, java.lang.String key, java.lang.String[] args, java.lang.String property)
      Constructor to create a message with a resource key.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Overwrites the method of the object class.
      java.lang.String getDescription()
      Gets the description of the message.
      java.lang.String getFieldId()
      Gets the field id.
      java.lang.String getMessageText()
      Determine the message text for the default locale given with Locale.getDefault().
      java.lang.String getMessageText​(java.util.Locale locale)
      Determines the message text for the given locale.
      java.lang.String getPageLocation()
      Gets the page location of the message.
      java.lang.String getPosition()
      Gets the position of the message.
      java.lang.String getProperty()
      Gets the name of the property to which the message belongs.
      TechKey getRefTechKey()
      Returns the property refTechKey.
      java.lang.String[] getResourceArgs()
      Returns the property resourceArgs.
      java.lang.String getResourceKey()
      Returns the property resourceKey.
      TechKey getTechKey()
      Returns the technical key of the message.
      int getType()
      Returns the type of the message.
      int hashCode()
      Returns hash code for the message.
      boolean isError()
      Returns if the message is an error message.
      boolean isInfo()  
      boolean isWarning()
      Returns if the message is a warning.
      void log​(org.apache.log4j.Logger logger)
      Logs the message in the given logger.
      void setDescription​(java.lang.String description)
      Sets the description of the message.
      void setFieldId​(java.lang.String fieldId)
      Sets the field id.
      void setModuleResourceAccess​(ModuleResourceAccess moduleResourceAccess)
      Sets the module resource access from outside (optional, e.g.
      void setPageLocation​(java.lang.String pagelocation)
      Sets the page location of the message.
      void setPosition​(java.lang.String position)
      Sets the position of the message.
      void setProperty​(java.lang.String property)
      Sets the name of the property to which the message belongs.
      void setRefTechKey​(TechKey refTechKey)
      Sets the property refTechKey.
      void setResourceArgs​(java.lang.String[] resourceArgs)
      Sets the property resourceArgs.
      void setResourceKey​(java.lang.String resourceKey)
      Sets the property resourceKey.
      void setTechKey​(TechKey techKey)
      Sets the techKey of the message.
      java.lang.String toString()
      Returns the object as string.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • INITIAL

        public static final int INITIAL
        Constant to define initial value.
        See Also:
        Constant Field Values
      • SUCCESS

        public static final int SUCCESS
        Constant to define message type success.
        See Also:
        Constant Field Values
      • ERROR

        public static final int ERROR
        Constant to define message type success.
        See Also:
        Constant Field Values
      • WARNING

        public static final int WARNING
        Constant to define message type warning.
        See Also:
        Constant Field Values
      • INFO

        public static final int INFO
        Constant to define message type info.
        See Also:
        Constant Field Values
      • DEBUG

        public static final int DEBUG
        Constant to define message type debug.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Message

        public Message​(int type,
                       java.lang.String key,
                       java.lang.String[] args,
                       java.lang.String property)
        Constructor to create a message with a resource key.
        Parameters:
        type - message type
        key - resource key to the message text
        args - 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

        public Message​(int type,
                       java.lang.String key,
                       java.lang.String property)
        Constructor to create a message with a resource key without args.
        Parameters:
        type - message type
        key - resource key to the message text
        property - name of property of a bean
      • Message

        public Message​(int type,
                       java.lang.String key)
        Constructor to create a message only with resource key.
        Parameters:
        type - message type
        key - resource key to the message text
    • Method Detail

      • setModuleResourceAccess

        public void setModuleResourceAccess​(ModuleResourceAccess moduleResourceAccess)
        Sets the module resource access from outside (optional, e.g. for tests)
        Parameters:
        moduleResourceAccess - module resource access
      • getMessageText

        public java.lang.String getMessageText​(java.util.Locale locale)
        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:
        ModuleResourceAccess
      • getMessageText

        public java.lang.String 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

        public java.lang.String getDescription()
        Gets the description of the message.
        Returns:
        description of the message
      • setDescription

        public void setDescription​(java.lang.String description)
        Sets the description of the message.
        Parameters:
        description - Description of the message
      • getPageLocation

        public java.lang.String getPageLocation()
        Gets the page location of the message.
        Returns:
        The page location
      • setPageLocation

        public void setPageLocation​(java.lang.String pagelocation)
        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

        public java.lang.String getPosition()
        Gets the position of the message.
        Returns:
        return the exact position where the message occurs
      • setPosition

        public void setPosition​(java.lang.String position)
        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

        public void setProperty​(java.lang.String property)
        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

        public java.lang.String getProperty()
        Gets the name of the property to which the message belongs.
        Returns:
        field name of the property to which the message belongs
      • setRefTechKey

        public void setRefTechKey​(TechKey refTechKey)
        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

        public TechKey getRefTechKey()
        Returns the property refTechKey.
        Returns:
        refTechKey
      • setResourceKey

        public void setResourceKey​(java.lang.String resourceKey)
        Sets the property resourceKey.
        Parameters:
        resourceKey - resource key
      • getResourceKey

        public java.lang.String getResourceKey()
        Returns the property resourceKey.
        Returns:
        resource key
      • setResourceArgs

        public void setResourceArgs​(java.lang.String[] resourceArgs)
        Sets the property resourceArgs.
        Parameters:
        resourceArgs - resource key arguments
      • getResourceArgs

        public java.lang.String[] 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

        public boolean equals​(java.lang.Object obj)
        Overwrites the method of the object class.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object which will be compare with the object
        Returns:
        true if the objects are equal
      • hashCode

        public int hashCode()
        Returns hash code for the message.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code of the objects
      • log

        public void log​(org.apache.log4j.Logger logger)
        Logs the message in the given logger.
        Parameters:
        logger - logger
      • toString

        public java.lang.String toString()
        Returns the object as string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String which contains all fields of the object
      • getTechKey

        public TechKey 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

        public void setTechKey​(TechKey techKey)
        Sets the techKey of the message.
        Parameters:
        techKey - the techKey to set
      • getFieldId

        public java.lang.String getFieldId()
        Gets the field id.
        Returns:
        field id
      • setFieldId

        public void setFieldId​(java.lang.String fieldId)
        Sets the field id.
        Parameters:
        fieldId - field id