aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java
index 394fb5b2..c8df0d5e 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketParser.java
@@ -4,16 +4,28 @@ import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
/**
- * Created by tzur on 15.01.2016.
+ * Parses the IQ Packets for handling pubsub
+ * as defined in XEP-0060.
+ * @see <a href="http://xmpp.org/extensions/xep-0060.html">http://xmpp.org/extensions/xep-0060.html</a>
+ */
+public final class PubSubPacketParser {
+ /**
+ * Finds the pubsub element within an IQ packet.
+ * @param packet the retrieved IQ packet
+ * @return the {@value PubSubPacket#ELEMENT_NAME} Element or <code>null</code> if the IqPacket is null or the IQ packet does not contain an pubsub element.
*/
-public class PubSubPacketParser {
public static Element findPubSubPacket(IqPacket packet){
if (null == packet) {
return null;
}
- return packet.findChild("pubsub", "http://jabber.org/protocol/pubsub");
+ return packet.findChild(PubSubPacket.ELEMENT_NAME, PubSubPacket.NAMESPACE);
}
+ /**
+ * Finds the "items" element within an pubSubPacket element.
+ * @param pubSubPacket the pubSubPacket element
+ * @return the items Element or <code>null</code> if the pubSubPacket is null or the pubSubPacket does not contain an items element.
+ */
public static Element findItemsFromPubSubElement(Element pubSubPacket) {
if (null == pubSubPacket) {
return null;
@@ -21,7 +33,19 @@ public class PubSubPacketParser {
return pubSubPacket.findChild("items");
}
+ /**
+ * Finds the "items" element within an pubSubPacket element.
+ * @param packet the IqPacket element
+ * @return the items Element or <code>null</code> if the IqPacket is null or the IQ packet does not contain an pubsub element with an items element.
+ */
public static Element findItems(IqPacket packet) {
return PubSubPacketParser.findItemsFromPubSubElement(PubSubPacketParser.findPubSubPacket(packet));
}
+
+ /**
+ * Utility class - avoid instantiation
+ */
+ private PubSubPacketParser() {
+ // Avoid instantiation
+ }
}