diff options
author | Sam Whited <sam@samwhited.com> | 2014-11-06 14:10:03 -0500 |
---|---|---|
committer | Sam Whited <sam@samwhited.com> | 2014-11-09 07:00:40 -0500 |
commit | f15900426d4713b48eb96e0ad0b1cdda5a86becf (patch) | |
tree | ffed4d06be23ca25c416f5463aceb36e20a5e4c3 /src/main/java/eu/siacs/conversations/xml | |
parent | 9053f4aca0c232db77dbd0a1e5b9b09bf41bec22 (diff) |
Update more files to use JID objects
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xml')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xml/Element.java | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java index 4e11ee2cd..31edec526 100644 --- a/src/main/java/eu/siacs/conversations/xml/Element.java +++ b/src/main/java/eu/siacs/conversations/xml/Element.java @@ -5,12 +5,14 @@ import java.util.Hashtable; import java.util.List; import eu.siacs.conversations.utils.XmlHelper; +import eu.siacs.conversations.xmpp.jid.InvalidJidException; +import eu.siacs.conversations.xmpp.jid.Jid; public class Element { protected String name; - protected Hashtable<String, String> attributes = new Hashtable<String, String>(); + protected Hashtable<String, String> attributes = new Hashtable<>(); protected String content; - protected List<Element> children = new ArrayList<Element>(); + protected List<Element> children = new ArrayList<>(); public Element(String name) { this.name = name; @@ -103,6 +105,42 @@ public class Element { } } + public Jid getJid() { + final String jid = this.getAttribute("jid"); + if (jid != null && !jid.isEmpty()) { + try { + return Jid.fromString(jid); + } catch (final InvalidJidException e) { + return null; + } + } + return null; + } + + public Jid getTo() { + final String to = this.getAttribute("to"); + if (to != null && !to.isEmpty()) { + try { + return Jid.fromString(to); + } catch (final InvalidJidException e) { + return null; + } + } + return null; + } + + public Jid getFrom() { + final String from = this.getAttribute("from"); + if (from != null && !from.isEmpty()) { + try { + return Jid.fromString(from); + } catch (final InvalidJidException e) { + return null; + } + } + return null; + } + public Hashtable<String, String> getAttributes() { return this.attributes; } |