Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5ad9e2090561a341e534e9981231c8b32ddbf4f8 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/****************************************************************************
 * 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.HashMap;
import java.util.Map;

import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.presence.IMMessage;

/**
 * Chat message concrete class. Implements IChatMessage.
 */
public class ChatMessage extends IMMessage implements IChatMessage {

	private static final long serialVersionUID = 483032454041915204L;

	protected ID threadID;

	protected IChatMessage.Type type;

	protected String subject;

	protected String body;

	protected Map properties;

	public ChatMessage(ID fromID, ID threadID, IChatMessage.Type type,
			String subject, String body, Map properties) {
		super(fromID);
		this.threadID = threadID;
		this.type = type;
		this.subject = subject;
		this.body = (body == null) ? "" : body; //$NON-NLS-1$
		this.properties = (properties == null) ? new HashMap() : properties;
	}

	public ChatMessage(ID fromID, ID threadID, String subject, String body,
			Map properties) {
		this(fromID, threadID, IChatMessage.Type.CHAT, subject, body,
				properties);
	}

	public ChatMessage(ID fromID, IChatMessage.Type type, String subject,
			String body, Map properties) {
		this(fromID, null, type, subject, body, properties);
	}

	public ChatMessage(ID fromID, String subject, String body, Map properties) {
		this(fromID, (ID) null, subject, body, properties);
	}

	public ChatMessage(ID fromID, String body, Map properties) {
		this(fromID, null, body, properties);
	}

	public ChatMessage(ID fromID, String body) {
		this(fromID, body, null);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.im.IChatMessage#getBody()
	 */
	public String getBody() {
		return body;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.im.IChatMessage#getSubject()
	 */
	public String getSubject() {
		return subject;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.im.IChatMessage#getThreadID()
	 */
	public ID getThreadID() {
		return threadID;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.im.IChatMessage#getType()
	 */
	public Type getType() {
		return type;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.im.IIMMessage#getProperties()
	 */
	public Map getProperties() {
		return properties;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		StringBuffer buf = new StringBuffer("ChatMessage["); //$NON-NLS-1$
		buf.append("fromID=").append(getFromID()); //$NON-NLS-1$
		buf.append(";threadID=").append(getThreadID()); //$NON-NLS-1$
		buf.append(";type=").append(getType()); //$NON-NLS-1$
		buf.append(";subject=").append(getSubject()); //$NON-NLS-1$
		buf.append(";body=").append(getBody()); //$NON-NLS-1$
		buf.append(";props=").append(getProperties()); //$NON-NLS-1$
		buf.append("]"); //$NON-NLS-1$
		return buf.toString();
	}

}

Back to the top