blob: 15178fad056807d96ef45be42f5101eeb8e5f8ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/****************************************************************************
* Copyright (c) 2004 Composent, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Composent, Inc. - initial API and implementation
*****************************************************************************/
package org.eclipse.ecf.presence.im;
import java.util.Map;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.presence.IIMMessage;
/**
* Chat message. This is the message received when another user sends a
* chat message to us.
*/
public interface IChatMessage extends IIMMessage {
/**
* Get thread ID for this message. If thread IDs are not supported,
* <code>null</code> will be returned.
*
* @return ID that identifies thread for this message. If threads are not
* supported by provider, will return <code>null</code>.
*/
public ID getThreadID();
/**
* Get subject for this message. If subjects are not supported, null will be
* returned.
*
* @return String that is the subject of this message. If subjects are not
* supported by provider, will return null.
*/
public String getSubject();
/**
* Get the message body for this message. Will not be null.
*
* @return String content/body of this message. Will not be null.
*/
public String getBody();
/**
* Get type for this message. Will not be null. Defaults to Type.CHAT.
*
* @return Type associated with this message. Defaults to Type.CHAT.
*/
public Type getType();
/**
* Get properties associated with this chat message
*
* @return Map of properties. Will not be null.
*/
public Map getProperties();
public static class Type {
private static final String CHAT_NAME = "chat"; //$NON-NLS-1$
private static final String SYSTEM_NAME = "system"; //$NON-NLS-1$
private static final String ERROR_NAME = "error"; //$NON-NLS-1$
private final transient String name;
// Protected constructor so that only subclasses are allowed to create
// instances
protected Type(String name) {
this.name = name;
}
public static Type fromString(String itemType) {
if (itemType == null)
return null;
if (itemType.equals(CHAT_NAME)) {
return CHAT;
} else if (itemType.equals(SYSTEM_NAME)) {
return SYSTEM;
} else if (itemType.equals(ERROR_NAME)) {
return ERROR;
} else
return null;
}
public static final Type CHAT = new Type(CHAT_NAME);
public static final Type SYSTEM = new Type(SYSTEM_NAME);
public static final Type ERROR = new Type(ERROR_NAME);
public String toString() {
return name;
}
// This is to make sure that subclasses don't screw up these methods
public final boolean equals(Object that) {
return super.equals(that);
}
public final int hashCode() {
return super.hashCode();
}
}
}
|