2014-10-22 12:38:44 -04:00
|
|
|
package eu.siacs.conversations.xmpp.stanzas;
|
|
|
|
|
2014-12-30 08:50:51 -05:00
|
|
|
import eu.siacs.conversations.entities.Account;
|
2014-10-22 12:38:44 -04:00
|
|
|
import eu.siacs.conversations.xml.Element;
|
2014-11-05 15:55:47 -05:00
|
|
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
2014-10-22 12:38:44 -04:00
|
|
|
|
|
|
|
public class AbstractStanza extends Element {
|
|
|
|
|
2014-12-30 08:50:51 -05:00
|
|
|
protected AbstractStanza(final String name) {
|
2014-10-22 12:38:44 -04:00
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
2014-11-06 14:10:03 -05:00
|
|
|
public Jid getTo() {
|
2014-12-15 11:29:17 -05:00
|
|
|
return getAttributeAsJid("to");
|
2014-11-09 10:18:53 -05:00
|
|
|
}
|
2014-11-06 14:10:03 -05:00
|
|
|
|
|
|
|
public Jid getFrom() {
|
2014-12-15 11:29:17 -05:00
|
|
|
return getAttributeAsJid("from");
|
2014-11-09 10:18:53 -05:00
|
|
|
}
|
2014-10-22 12:38:44 -04:00
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
return this.getAttribute("id");
|
|
|
|
}
|
|
|
|
|
2014-11-05 15:55:47 -05:00
|
|
|
public void setTo(final Jid to) {
|
2014-11-17 14:45:00 -05:00
|
|
|
if (to != null) {
|
|
|
|
setAttribute("to", to.toString());
|
|
|
|
}
|
2014-10-22 12:38:44 -04:00
|
|
|
}
|
|
|
|
|
2014-11-05 15:55:47 -05:00
|
|
|
public void setFrom(final Jid from) {
|
2014-11-17 14:45:00 -05:00
|
|
|
if (from != null) {
|
|
|
|
setAttribute("from", from.toString());
|
|
|
|
}
|
2014-10-22 12:38:44 -04:00
|
|
|
}
|
|
|
|
|
2014-11-05 15:55:47 -05:00
|
|
|
public void setId(final String id) {
|
2014-10-22 12:38:44 -04:00
|
|
|
setAttribute("id", id);
|
|
|
|
}
|
2014-12-30 08:50:51 -05:00
|
|
|
|
|
|
|
public boolean fromServer(final Account account) {
|
|
|
|
return getFrom() == null
|
|
|
|
|| getFrom().equals(account.getServer())
|
|
|
|
|| getFrom().equals(account.getJid().toBareJid())
|
|
|
|
|| getFrom().equals(account.getJid());
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean toServer(final Account account) {
|
|
|
|
return getTo() == null
|
|
|
|
|| getTo().equals(account.getServer())
|
|
|
|
|| getTo().equals(account.getJid().toBareJid())
|
|
|
|
|| getTo().equals(account.getJid());
|
|
|
|
}
|
2014-10-22 12:38:44 -04:00
|
|
|
}
|