Class MessageContent
-
- All Implemented Interfaces:
public abstract class MessageContentThe base class for messages.
Defines methods for converting between message objects and message data.
-
-
Field Summary
Fields Modifier and Type Field Description public UserInfouserInfopublic MentionedInfomentionedInfopublic booleanisDestructpublic longdestructTimepublic MessageAuditInfoauditInfopublic Array<byte>rawJsonData
-
Constructor Summary
Constructors Constructor Description MessageContent(Array<byte> data)Deserializes message data into a local message object.
-
Method Summary
Modifier and Type Method Description UserInfogetUserInfo()Get user information voidsetUserInfo(UserInfo info)Set user information MentionedInfogetMentionedInfo()Get @user information voidsetMentionedInfo(MentionedInfo info)Set @ user information booleanisDestruct()Indicates whether the message is set to auto-destroy after a certain time. voidsetDestruct(boolean destruct)Sets whether the message is timed-destruct. longgetDestructTime()Retrieves the auto-destroy time. voidsetDestructTime(long destructTime)Sets the self-destruct timer. MessageAuditInfogetAuditInfo()Retrieves the message moderation configuration voidsetAuditInfo(MessageAuditInfo auditInfo)Set message moderation configuration Array<byte>getRawJsonData()Retrieves the raw binary data of the message. voidsetRawJsonData(Array<byte> rawJsonData)Sets the raw binary data of the message. abstract Array<byte>encode()Serializes the local message object into message data. JSONObjectgetBaseJsonObject()Converts the self-destruct field, @ mention field, user info field, and extra field of the base class into a JSONObject. voidparseBaseJsonObject(JSONObject jsonObject)Parses the self-destruct field, @ mention field, user information field, and extra field from the JSONObject into the message body. voidwriteToBaseInfoParcel(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. voidreadFromBaseInfoParcel(Parcel in)JSONObjectgetJSONDestructInfo()voidparseJsonToDestructInfo(JSONObject jsonObject)JSONObjectgetJSONUserInfo()UserInfoparseJsonToUserInfo(JSONObject jsonObj)Parses the user JSON object List<String>getSearchableWord()Returns the searchable content within the message body. StringgetExtra()Get message extension information voidsetExtra(String extra)Sets the message extended information -
-
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.
-
getJSONDestructInfo
JSONObject getJSONDestructInfo()
-
parseJsonToDestructInfo
void parseJsonToDestructInfo(JSONObject jsonObject)
-
getJSONUserInfo
JSONObject getJSONUserInfo()
-
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
-
-
-
-