public class ChatMessage extends RequestListActions implements JsonConstructable
Each element in this list is a message in a hosted chat. The primary key for each element is the 'chatId' and 'messageId'.
The range of valid message ids for a given chat can be found in the chat list as ['lastMessage' - 'numMessages', 'lastMessage'].
When a new message is added to a chat, bbmcore will first 'listAdd' the message entry, and then will 'listChange' the chat to update the 'lastMessage' and 'numMessages' fields.
Note that 'listRemove' is not supported for this list. The message counters maintained in the chat list indicate when messages have been removed from this list.
Modifier and Type | Class and Description |
---|---|
static class |
ChatMessage.ChatMessageKey
Creates a new ChatMessageKey instance
|
static class |
ChatMessage.FileState
Indicates the state of file upload or download.
|
static class |
ChatMessage.Flags
Compact read-only flags about the message.
|
static class |
ChatMessage.Recall
This field indicates the recall state of the message.
|
static class |
ChatMessage.State
This field indicates the overall delivery state of the message.
|
static interface |
ChatMessage.Tag
Indicates the type of content this message represents.
|
Modifier and Type | Field and Description |
---|---|
java.lang.String |
chatId
The unique identifier of the chat to which this message belongs.
|
java.lang.String |
content
Holds the text content of the message, when the 'tag' has such a concept;
otherwise omitted.
|
JSONObject |
data
This field contains opaque data managed by the app that is sent with the
message.
|
Existence |
exists
Determines whether the data in this object is valid.
|
java.lang.String |
file
A path to a large file that is not carried in the message.
|
ChatMessage.FileState |
fileState
Indicates the state of file upload or download.
|
java.lang.String |
flags
Compact read-only flags about the message.
|
long |
messageId
The unique identifier for this message.
|
ChatMessage.Recall |
recall
This field indicates the recall state of the message.
|
java.lang.String |
senderUri
Holds the URI of the sender of this message.
|
ChatMessage.State |
state
This field indicates the overall delivery state of the message.
|
boolean |
stateIsPartial
This indicates whether or not the state applies to some (true) or all (false)
recipients.
|
java.lang.String |
tag
Indicates the type of content this message represents.
|
java.lang.String |
thumb
A path to a small file that is carried in the message.
|
long |
timestamp
Holds the POSIX timestamp of the message.
|
Constructor and Description |
---|
ChatMessage()
Creates a new instance with default values
|
ChatMessage(ChatMessage toCopy)
Creates a shallow copy of the argument.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Existence |
getExists()
See
Existence |
ChatMessage.ChatMessageKey |
getPrimaryKey()
Provides the unique key for this ChatMessage
|
boolean |
hasFlag(ChatMessage.Flags flag)
Check if the Flags string contains the given flag.
|
int |
hashCode() |
ChatMessage |
setAttributes(JSONObject json)
Updates the the attributes of the
JsonConstructable based on the values in the JSONObject |
void |
setExists(Existence exists)
See
Existence |
JsonConstructable |
shallowCopy()
Creates a shallow copy of the receiver
|
java.lang.String |
toString() |
requestListAdd, requestListChange, requestListRemove
public java.lang.String chatId
public java.lang.String content
public JSONObject data
This field contains opaque data managed by the app that is sent with the message. Unless specifically noted, bbmcore does not examine or modify this JSON object.
This can contain a single JSON object, or it can not exist at all. It cannot contain any other JSON type.
Many 'tag' values have a corresponding object defined as a child of the 'data' object with a key equal to the 'tag'. All 'tags' with such a corresponding child of 'data' require that child to be present. Other tags have no such requirement.
The 'data' object can also contain other key-value pairs independently from the 'tag'.
public java.lang.String file
public ChatMessage.FileState fileState
Indicates the state of file upload or download.
Generally, whether the transfer is an upload or download is not exposed to the app. However, some states imply that the transfer is a download that can be started or restarted by the 'chatMessageFileDownload' message. The 'incoming' 'flag' on this 'chatMessage' does not indicate whether the transfer is an upload or download.
Bbmcore automatically handles temporary errors during uploads and downloads. Such errors and the retries that occur are not exposed to the app. Eventually, bbmcore will give up and place a transfer into either the 'Failed' or 'FailedAvailable' state.
public java.lang.String flags
public long messageId
public ChatMessage.Recall recall
public java.lang.String senderUri
public ChatMessage.State state
public boolean stateIsPartial
public java.lang.String tag
public java.lang.String thumb
public long timestamp
public Existence exists
public ChatMessage()
public ChatMessage(ChatMessage toCopy)
toCopy
- the object to copypublic boolean hasFlag(ChatMessage.Flags flag)
flag
- the read-only flag to checkpublic ChatMessage.ChatMessageKey getPrimaryKey()
getPrimaryKey
in interface JsonConstructable
public ChatMessage setAttributes(JSONObject json)
JsonConstructable
JsonConstructable
based on the values in the JSONObject
setAttributes
in interface JsonConstructable
json
- The JSONObject used to update the attributes of this JsonConstructable
public JsonConstructable shallowCopy()
JsonConstructable
shallowCopy
in interface JsonConstructable
public void setExists(Existence exists)
JsonConstructable
Existence
setExists
in interface JsonConstructable
exists
- sets the expected Existence value on the object.public Existence getExists()
JsonConstructable
Existence
getExists
in interface JsonConstructable
Existence.MAYBE
, Existence.YES
or Existence.NO
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object