summaryrefslogtreecommitdiffstats
blob: 44d21ced760f46c8474a42567b0d5df21299bd3a (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
/*
* Copyright (c) 2014 Kevin Smith and Remko Tronçon
* All rights reserved.
*/

/*
* Copyright (c) 2014, Isode Limited, London, England.
* All rights reserved.
*/

package com.isode.stroke.parser.payloadparsers;

import java.util.Date;
import com.isode.stroke.base.DateTime;
import com.isode.stroke.elements.Delay;
import com.isode.stroke.jid.JID;
import com.isode.stroke.parser.AttributeMap;
import com.isode.stroke.parser.GenericPayloadParser;

public class DelayParser extends GenericPayloadParser<Delay> {
    
    public DelayParser() {
        super(new Delay());
    }

    public void handleStartElement(String element, String ns, AttributeMap attributes) {
        if (level_ == 0) {
            Date stamp = DateTime.stringToDate(attributes.getAttribute("stamp"));
            getPayloadInternal().setStamp(stamp);
            if (!attributes.getAttribute("from").isEmpty()) {
                String from = attributes.getAttribute("from");
                getPayloadInternal().setFrom(new JID(from));
            }
        }
        ++level_;
    }
    
    public void handleEndElement(String element, String ns) {
        --level_;
    }
    
    public void handleCharacterData(String data) {
    }

    private int level_;
}