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 String getErrorCondition() {
35 Element error = findChild("error");
36 if (error != null) {
37 for(Element element : error.getChildren()) {
38 if (!element.getName().equals("text")) {
39 return element.getName();
40 }
41 }
42 }
43 return null;
44 }
45
46 public boolean valid() {
47 return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
48 }
49}