summaryrefslogtreecommitdiffstats
blob: f11cceab922ecede28ba12856483743d437815cf (plain)
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
/*
 * Copyright (c) 2010 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */
/*
 * Copyright (c) 2015 Tarun Gupta.
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

package com.isode.stroke.serializer.payloadserializers;

import com.isode.stroke.serializer.GenericPayloadSerializer;
import com.isode.stroke.elements.ChatState;
import com.isode.stroke.base.NotNull;

public class ChatStateSerializer extends GenericPayloadSerializer<ChatState> {

	/**
	* CapsInfoSerializer();
	*/
	public ChatStateSerializer() {
		super(ChatState.class);
	}

	/**
	* @param chatState, notnull
	*/
	@Override
	protected String serializePayload(ChatState chatState) {
		NotNull.exceptIfNull(chatState, "chatState");
		String result = "<";
		ChatState.ChatStateType state = chatState.getChatState();
		if (state == ChatState.ChatStateType.Active) {
			result = result.concat("active");
		} else if (state == ChatState.ChatStateType.Composing) {
			result = result.concat("composing");
		} else if (state == ChatState.ChatStateType.Paused) {
			result = result.concat("paused");
		} else if (state == ChatState.ChatStateType.Inactive) {
			result = result.concat("inactive");	
		} else if (state == ChatState.ChatStateType.Gone) {
			result = result.concat("gone");
		}
		result = result.concat(" xmlns=\"http://jabber.org/protocol/chatstates\"/>");
		return result;
	}
}