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

import com.isode.stroke.elements.IQ;

public class IQParser extends GenericStanzaParser<IQ> {

    public IQParser(PayloadParserFactoryCollection factories) {
        super(factories, new IQ());
    }

    @Override
    void handleStanzaAttributes(AttributeMap attributes) {
        String type = attributes.getAttribute("type");
        if ("set".equals(type)) {
            getStanzaGeneric().setType(IQ.Type.Set);
        } else if ("get".equals(type)) {
            getStanzaGeneric().setType(IQ.Type.Get);
        } else if ("result".equals(type)) {
            getStanzaGeneric().setType(IQ.Type.Result);
        } else if ("error".equals(type)) {
            getStanzaGeneric().setType(IQ.Type.Error);
        } else {
            getStanzaGeneric().setType(IQ.Type.Get);
        }
    }
}