conversations-classic/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractAcknowledgeableStanza.java

50 lines
1 KiB
Java
Raw Normal View History

2015-08-13 16:25:10 +00:00
package eu.siacs.conversations.xmpp.stanzas;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.InvalidJid;
import rocks.xmpp.addr.Jid;
2015-08-13 16:25:10 +00:00
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 String getErrorCondition() {
Element error = findChild("error");
if (error != null) {
for(Element element : error.getChildren()) {
if (!element.getName().equals("text")) {
return element.getName();
}
}
}
return null;
}
public boolean valid() {
return InvalidJid.isValid(getFrom()) && InvalidJid.isValid(getTo());
}
2015-08-13 16:25:10 +00:00
}