1package eu.siacs.conversations.xmpp.stanzas;
2
3import eu.siacs.conversations.xml.Element;
4import eu.siacs.conversations.xmpp.InvalidJid;
5import rocks.xmpp.addr.Jid;
6
7abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
8
9 protected AbstractAcknowledgeableStanza(String name) {
10 super(name);
11 }
12
13
14 public String getId() {
15 return this.getAttribute("id");
16 }
17
18 public void setId(final String id) {
19 setAttribute("id", id);
20 }
21
22 public Element getError() {
23 Element error = findChild("error");
24 if (error != null) {
25 for(Element element : error.getChildren()) {
26 if (!element.getName().equals("text")) {
27 return element;
28 }
29 }
30 }
31 return null;
32 }
33
34 public boolean valid() {
35 return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
36 }
37}