From 7382e3af9769f76fe4e19934a59e45a3f9858332 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 3 May 2015 22:25:46 +0200 Subject: renaming eu.siacs.conversations to de.thedevstack.conversationsplus "renaming eu.siacs.conversations to de.thedevstack.conversationsplus" package renaming completed --- .../xmpp/stanzas/AbstractStanza.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/AbstractStanza.java (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/AbstractStanza.java') diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/AbstractStanza.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/AbstractStanza.java new file mode 100644 index 00000000..d326a214 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/AbstractStanza.java @@ -0,0 +1,54 @@ +package de.thedevstack.conversationsplus.xmpp.stanzas; + +import de.thedevstack.conversationsplus.entities.Account; +import de.thedevstack.conversationsplus.xml.Element; +import de.thedevstack.conversationsplus.xmpp.jid.Jid; + +public class AbstractStanza extends Element { + + protected AbstractStanza(final String name) { + super(name); + } + + public Jid getTo() { + return getAttributeAsJid("to"); + } + + public Jid getFrom() { + return getAttributeAsJid("from"); + } + + public String getId() { + return this.getAttribute("id"); + } + + public void setTo(final Jid to) { + if (to != null) { + setAttribute("to", to.toString()); + } + } + + public void setFrom(final Jid from) { + if (from != null) { + setAttribute("from", from.toString()); + } + } + + public void setId(final String id) { + setAttribute("id", id); + } + + 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()); + } +} -- cgit v1.2.3