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