Class MessageContent

  • All Implemented Interfaces:

    
    public abstract class MessageContent
    
                        

    The base class for messages.

    Defines methods for converting between message objects and message data.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageContent(Array<byte> data) Deserializes message data into a local message object.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      UserInfo getUserInfo() Get user information
      void setUserInfo(UserInfo info) Set user information
      MentionedInfo getMentionedInfo() Get @user information
      void setMentionedInfo(MentionedInfo info) Set @ user information
      boolean isDestruct() Indicates whether the message is set to auto-destroy after a certain time.
      void setDestruct(boolean destruct) Sets whether the message is timed-destruct.
      long getDestructTime() Retrieves the auto-destroy time.
      void setDestructTime(long destructTime) Sets the self-destruct timer.
      MessageAuditInfo getAuditInfo() Retrieves the message moderation configuration
      void setAuditInfo(MessageAuditInfo auditInfo) Set message moderation configuration
      Array<byte> getRawJsonData() Retrieves the raw binary data of the message.
      void setRawJsonData(Array<byte> rawJsonData) Sets the raw binary data of the message.
      abstract Array<byte> encode() Serializes the local message object into message data.
      JSONObject getBaseJsonObject() Converts the self-destruct field, @ mention field, user info field, and extra field of the base class into a JSONObject.
      void parseBaseJsonObject(JSONObject jsonObject) Parses the self-destruct field, @ mention field, user information field, and extra field from the JSONObject into the message body.
      void writeToBaseInfoParcel(Parcel dest) Writes the data of the base class's self-destruct field, @ mention field, user information field, and extra field into the externally provided Parcel.
      void readFromBaseInfoParcel(Parcel in)
      JSONObject getJSONDestructInfo()
      void parseJsonToDestructInfo(JSONObject jsonObject)
      JSONObject getJSONUserInfo()
      UserInfo parseJsonToUserInfo(JSONObject jsonObj) Parses the user JSON object
      List<String> getSearchableWord() Returns the searchable content within the message body.
      String getExtra() Get message extension information
      void setExtra(String extra) Sets the message extended information
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageContent

        MessageContent(Array<byte> data)
        Deserializes message data into a local message object.
        Parameters:
        data - The message data.
    • Method Detail

      • getUserInfo

         UserInfo getUserInfo()

        Get user information

        Returns:

        User information

      • setUserInfo

         void setUserInfo(UserInfo info)

        Set user information

        Parameters:
        info - User information
      • getMentionedInfo

         MentionedInfo getMentionedInfo()

        Get @user information

        Returns:

        @user information

      • setMentionedInfo

         void setMentionedInfo(MentionedInfo info)

        Set @ user information

        Parameters:
        info - @ user information
      • isDestruct

         boolean isDestruct()

        Indicates whether the message is set to auto-destroy after a certain time.

        Returns:

        Indicates whether the message is set to auto-destroy after a certain time.

      • setDestruct

         void setDestruct(boolean destruct)

        Sets whether the message is timed-destruct.

        Parameters:
        destruct - Indicates whether the message is timed-destruct.
      • getDestructTime

         long getDestructTime()

        Retrieves the auto-destroy time. If isDestruct is false, the message will be destroyed after the specified destructTime once it is marked as read.

        Returns:

        The auto-destroy time. If isDestruct is false, the message will be destroyed after the specified destructTime once it is marked as read.

      • setDestructTime

         void setDestructTime(long destructTime)

        Sets the self-destruct timer. If isDestruct is false, the message will be destroyed after the specified destructTime elapses once it is marked as read.

        Parameters:
        destructTime - Specifies the self-destruct timer.
      • getAuditInfo

         MessageAuditInfo getAuditInfo()

        Retrieves the message moderation configuration

        Returns:

        The message moderation configuration

      • setAuditInfo

         void setAuditInfo(MessageAuditInfo auditInfo)

        Set message moderation configuration

        Parameters:
        auditInfo - Message moderation configuration
      • getRawJsonData

         Array<byte> getRawJsonData()

        Retrieves the raw binary data of the message. This method is only valid in the IPC process and not in the main process.

        Returns:

        Binary data

      • setRawJsonData

         void setRawJsonData(Array<byte> rawJsonData)

        Sets the raw binary data of the message. This is only valid in the IPC process and has no effect in the main process.

        Parameters:
        rawJsonData - The binary data
      • encode

         abstract Array<byte> encode()

        Serializes the local message object into message data.

        Returns:

        The message data.

      • getBaseJsonObject

         JSONObject getBaseJsonObject()

        Converts the self-destruct field, @ mention field, user info field, and extra field of the base class into a JSONObject.

        Returns:

        A JSONObject containing the above fields.

      • parseBaseJsonObject

         void parseBaseJsonObject(JSONObject jsonObject)

        Parses the self-destruct field, @ mention field, user information field, and extra field from the JSONObject into the message body.

        Parameters:
        jsonObject - The JSONObject containing the above fields.
      • writeToBaseInfoParcel

         void writeToBaseInfoParcel(Parcel dest)

        Writes the data of the base class's self-destruct field, @ mention field, user information field, and extra field into the externally provided Parcel.

        Parameters:
        dest - The Parcel into which the object is written.
      • readFromBaseInfoParcel

         void readFromBaseInfoParcel(Parcel in)
        Parameters:
        in - The Parcel passed to initialize the self-destruct field, @mention field, user information field, and extra field in the base class.
      • parseJsonToUserInfo

         UserInfo parseJsonToUserInfo(JSONObject jsonObj)

        Parses the user JSON object

        Parameters:
        jsonObj - The JSON object of the user
      • getSearchableWord

         List<String> getSearchableWord()

        Returns the searchable content within the message body. If developers want to enable custom message content to be searchable, they need to implement this method and return the searchable content.

        Returns:

        The searchable content; if the message contains multiple fields, each field can be populated into a List; for example, the title and summary of a graphic message.

      • getExtra

         String getExtra()

        Get message extension information

        Returns:

        Extended Information

      • setExtra

         void setExtra(String extra)

        Sets the message extended information

        Parameters:
        extra - Extended Information