aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java
blob: e795b40fd9eb08ec3a08890ec3fa1ef08bb7bfa7 (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
package de.pixart.messenger.xmpp.stanzas;

import de.pixart.messenger.xml.Element;
import de.pixart.messenger.xmpp.InvalidJid;

abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {

    protected AbstractAcknowledgeableStanza(String name) {
        super(name);
    }


    public String getId() {
        return this.getAttribute("id");
    }

    public void setId(final String id) {
        setAttribute("id", id);
    }

    public Element getError() {
        Element error = findChild("error");
        if (error != null) {
            for (Element element : error.getChildren()) {
                if (!element.getName().equals("text")) {
                    return element;
                }
            }
        }
        return null;
    }

    public boolean valid() {
        return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
    }
}