summaryrefslogtreecommitdiffstats
blob: b97197c91fef8dfaf43e6e552ed406b928a23613 (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
/*
 * Copyright (c) 2010, Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010, Remko Tronçon.
 * All rights reserved.
 */
package com.isode.stroke.serializer;

import com.isode.stroke.elements.IQ;
import com.isode.stroke.serializer.xml.XMLElement;

public class IQSerializer extends GenericStanzaSerializer<IQ> {

    public IQSerializer(PayloadSerializerCollection payloadSerializers) {
        this(payloadSerializers, null);
    }

    public IQSerializer(PayloadSerializerCollection payloadSerializers, String explicitNS) {
        super(IQ.class, "iq", payloadSerializers, explicitNS);
    }

    @Override
    void setStanzaSpecificAttributesGeneric(IQ iq, XMLElement element) {
        switch (iq.getType()) {
            case Get:
                element.setAttribute("type", "get");
                break;
            case Set:
                element.setAttribute("type", "set");
                break;
            case Result:
                element.setAttribute("type", "result");
                break;
            case Error:
                element.setAttribute("type", "error");
                break;
        }
    }
}