3
3
import org .jivesoftware .database .JiveID ;
4
4
import org .xmpp .packet .JID ;
5
5
6
+ import javax .annotation .Nonnull ;
7
+ import javax .annotation .Nullable ;
8
+ import javax .annotation .concurrent .Immutable ;
6
9
import java .util .Date ;
7
10
8
11
/**
9
12
* An archived message.
10
13
*/
11
14
@ JiveID (601 )
15
+ @ Immutable
12
16
public class ArchivedMessage {
13
17
public enum Direction {
14
18
/**
@@ -22,15 +26,28 @@ public enum Direction {
22
26
from
23
27
}
24
28
29
+ @ Nullable
25
30
private final Long id ;
31
+
32
+ @ Nonnull
26
33
private final Date time ;
34
+
35
+ @ Nonnull
27
36
private final Direction direction ;
37
+
38
+ @ Nullable
28
39
private final String body ;
40
+
41
+ @ Nullable
29
42
private final JID with ;
43
+
44
+ @ Nullable
30
45
private final String stanza ;
46
+
47
+ @ Nullable
31
48
private final String stableId ;
32
49
33
- public ArchivedMessage ( Long id , Date time , Direction direction , JID with , String stableId , String body , String stanza ) {
50
+ public ArchivedMessage (@ Nullable final Long id , @ Nonnull final Date time , @ Nonnull final Direction direction , @ Nullable final JID with , @ Nullable final String stableId , @ Nullable final String body , @ Nullable final String stanza ) {
34
51
this .id = id ;
35
52
this .time = time ;
36
53
this .direction = direction ;
@@ -40,30 +57,80 @@ public ArchivedMessage( Long id, Date time, Direction direction, JID with, Strin
40
57
this .stanza = stanza ;
41
58
}
42
59
60
+ /**
61
+ * The database identifier used to store this message. Expected to be non-null, unless an instance has not been
62
+ * persisted in the database yet.
63
+ *
64
+ * @return A database identifier
65
+ */
66
+ @ Nullable
43
67
public Long getId () {
44
68
return id ;
45
69
}
46
70
71
+ /**
72
+ * The instant when the message was originally sent.
73
+ *
74
+ * @return date that the message wos originally sent.
75
+ */
76
+ @ Nonnull
47
77
public Date getTime () {
48
78
return time ;
49
79
}
50
80
81
+ /**
82
+ * Defines if the message was originally sent, or received, by the owner of the archive that this message is part of.
83
+ *
84
+ * @return indication if message was originally sent or received.
85
+ */
86
+ @ Nonnull
51
87
public Direction getDirection () {
52
88
return direction ;
53
89
}
54
90
91
+ /**
92
+ * The textual content of the message that was sent, if the message had any text.
93
+ *
94
+ * @return Message content
95
+ */
96
+ @ Nullable
55
97
public String getBody () {
56
98
return body ;
57
99
}
58
100
101
+ /**
102
+ * The XML representation of the XMPP stanza that was used to transmit the message.
103
+ *
104
+ * Note that older version of the Monitoring plugin did not store the XMPP stanza to the database. As a result,
105
+ * messages that were archived by those versions of the plugin do not include a stanza.
106
+ *
107
+ * @return XMPP packet
108
+ */
109
+ @ Nullable
59
110
public String getStanza () {
60
111
return stanza ;
61
112
}
62
113
114
+ /**
115
+ * The message peer (the 'other side' of the conversation), in respect to the owner of the archive that this message
116
+ * is part of.
117
+ *
118
+ * This value will only have meaning when the original message was sent in a one-to-one conversation. When the
119
+ * archived message was originally shared in a group chat, this value can be null.
120
+ *
121
+ * @return The conversation peer.
122
+ */
123
+ @ Nullable
63
124
public JID getWith () {
64
125
return with ;
65
126
}
66
127
128
+ /**
129
+ * The first stable and unique stanza-id value in the stanza, if the stanza contains such a value.
130
+ *
131
+ * @return a stable and unique stanza-id value.
132
+ */
133
+ @ Nullable
67
134
public String getStableId ()
68
135
{
69
136
return stableId ;
0 commit comments