Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fist commit

  • Loading branch information...
commit e14d106c3ca9ff163c3d5e69a5e041eaa217689d 1 parent 8c731bc
@mastooo mastooo authored
Showing with 1,126 additions and 2 deletions.
  1. +1 −2  README
  2. +25 −0 build.xml
  3. BIN  lib/smack.jar
  4. +13 −0 licences/smack.txt
  5. +38 −0 src/META-INF/smack.providers
  6. +38 −0 src/org/superfeedr/OnNotificationHandler.java
  7. +166 −0 src/org/superfeedr/Superfeedr.java
  8. +40 −0 src/org/superfeedr/extension/DefaultSuperfeerExtension.java
  9. +101 −0 src/org/superfeedr/extension/EntryExtension.java
  10. +49 −0 src/org/superfeedr/extension/HttpExtension.java
  11. +38 −0 src/org/superfeedr/extension/ItemExtension.java
  12. +61 −0 src/org/superfeedr/extension/ItemsExtension.java
  13. +57 −0 src/org/superfeedr/extension/StatusExtension.java
  14. +57 −0 src/org/superfeedr/extension/SuperfeedrEventExtension.java
  15. +66 −0 src/org/superfeedr/provider/EmbeddedExtensionProvider.java
  16. +71 −0 src/org/superfeedr/provider/EntryProvider.java
  17. +40 −0 src/org/superfeedr/provider/EventProvider.java
  18. +49 −0 src/org/superfeedr/provider/HttpProvider.java
  19. +41 −0 src/org/superfeedr/provider/ItemProvider.java
  20. +38 −0 src/org/superfeedr/provider/ItemsProvider.java
  21. +37 −0 src/org/superfeedr/provider/NextFetchProvider.java
  22. +43 −0 src/org/superfeedr/provider/StatusProvider.java
  23. +57 −0 src/org/superfeedr/test/Test.java
View
3  README
@@ -3,7 +3,6 @@ A java client library for SuperFeedr
Dependency :
Smack 3.1 (http://www.igniterealtime.org/downloads/index.jsp)
-smackx-pubsub extension to Smack (http://github.com/squaremo/smackx-pubsub/tree/master)
Java 5+
-
+Thomas RICARD, July 2009
View
25 build.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project basedir="." default="build" name="Superfeedr">
+
+ <property name="build" value="${basedir}/build" />
+ <property name="distrib" value="${basedir}/distrib" />
+ <property name="source" value="${basedir}/src" />
+ <property name="lib" value="${basedir}/lib" />
+
+ <target name="cleanup">
+ <delete dir="${build}"/>
+ <mkdir dir="${build}"/>
+ <delete file="${distrib}}/superfeedr.jar"/>
+ </target>
+
+ <target name="build" depends="cleanup">
+ <javac srcdir="${source}" destdir="${build}" source="1.5" classpath="${lib}/smack.jar"/>
+ <copy todir="${build}/META-INF">
+ <fileset dir="${source}/META-INF"/>
+ </copy>
+ </target>
+
+ <target name="jar" depends="build">
+ <jar destfile="${distrib}/superfeedr.jar" basedir="${build}" excludes="**/test/*"></jar>
+ </target>
+</project>
View
BIN  lib/smack.jar
Binary file not shown
View
13 licences/smack.txt
@@ -0,0 +1,13 @@
+Copyright 2002-2008 Jive Software.
+
+ All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
38 src/META-INF/smack.providers
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<smackProviders>
+ <extensionProvider>
+ <elementName>event</elementName>
+ <namespace>http://jabber.org/protocol/pubsub#event</namespace>
+ <className>org.superfeedr.provider.EventProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>status</elementName>
+ <namespace>http://superfeedr.com/xmpp-pubsub-ext</namespace>
+ <className>org.superfeedr.provider.StatusProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>http</elementName>
+ <namespace>http://superfeedr.com/xmpp-pubsub-ext</namespace>
+ <className>org.superfeedr.provider.HttpProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>next_fetch</elementName>
+ <namespace>http://superfeedr.com/xmpp-pubsub-ext</namespace>
+ <className>org.superfeedr.provider.NextFetchProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>items</elementName>
+ <namespace>http://jabber.org/protocol/pubsub#event</namespace>
+ <className>org.superfeedr.provider.ItemsProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>item</elementName>
+ <namespace>http://jabber.org/protocol/pubsub#event</namespace>
+ <className>org.superfeedr.provider.ItemProvider</className>
+ </extensionProvider>
+ <extensionProvider>
+ <elementName>entry</elementName>
+ <namespace>http://www.w3.org/2005/Atom</namespace>
+ <className>org.superfeedr.provider.EntryProvider</className>
+ </extensionProvider>
+</smackProviders>
View
38 src/org/superfeedr/OnNotificationHandler.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr;
+
+import org.superfeedr.extension.SuperfeedrEventExtension;
+
+/**
+ * This interface must be implemented by the classes that need to be notified on events
+ * @author thomas
+ *
+ */
+public interface OnNotificationHandler {
+
+ /**
+ * This method is called when an event is sent by the Superfeedr server. The event can be with no items.
+ * @param event the event received from the superfeedr server
+ */
+ public void onNotification(SuperfeedrEventExtension event);
+}
View
166 src/org/superfeedr/Superfeedr.java
@@ -0,0 +1,166 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.filter.PacketTypeFilter;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+import org.superfeedr.extension.SuperfeedrEventExtension;
+
+/**
+ * The SuperFeedr Class is the entry point to access the superFeedr XMPP
+ * functionnalities. To use this Class, you should already have a superfeedr
+ * account.
+ *
+ * @author thomas RICARD
+ *
+ */
+public class Superfeedr implements PacketListener {
+
+ // The pseudo ISO 8601 date formatter that misses the timezone (thanks to
+ // java)
+ private static DateFormat m_ISO8601Local = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+
+ /**
+ * This class converts a ISO 8601 date represented as a string to a java
+ * Date Object
+ *
+ * @param date
+ * @return
+ */
+ public static Date convertDate(final String date) {
+ try {
+ return m_ISO8601Local.parse(date);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return new Date();
+ }
+ }
+
+ // The current connection to the XMPP server
+ private XMPPConnection connection;
+
+ // The JID used by this superfeedR instance
+ private String jid;
+
+ // The Listeners of event on this superfeedr instance
+ private ArrayList<OnNotificationHandler> onNotificationHandlers = new ArrayList<OnNotificationHandler>();
+
+ // The server this instance is connected to
+ private String server;
+
+ /**
+ * Constructor of a superfeedr instance that will connect to the specified
+ * server using the jid and password as credentials
+ *
+ * @param jid
+ * the jid you want to connect with
+ * @param password
+ * the password to use
+ * @param server
+ * the server you connect to
+ */
+ public Superfeedr(final String jid, final String password, final String server) throws XMPPException {
+ if (jid == null || password == null || server == null)
+ throw new IllegalArgumentException("arguments cannot be null");
+
+ this.jid = jid;
+ this.server = server;
+
+ // Creating the connection to the XMPP server
+ connection = new XMPPConnection(this.server);
+
+ // Now, time to connect and auth
+ try {
+ connection.connect();
+ connection.login(this.jid, password);
+ connection.addPacketListener(this, new PacketTypeFilter(Message.class));
+ } catch (XMPPException e) {
+ if (connection != null && connection.isConnected()) {
+ connection.disconnect();
+ }
+ // Let the caller deal with the exception
+ throw e;
+ }
+ }
+
+ /**
+ * This method is used to close the connection to the Superfeer Server.
+ * @throws XMPPException
+ */
+ public void close() throws XMPPException{
+ if (connection != null && connection.isConnected()) {
+ connection.disconnect();
+ }
+ }
+
+ /**
+ * Add handler as a notification handler on this superfeedr. When a
+ * notification is received, a SuperfeedrEventExtension object is created
+ * and passed to each listener
+ *
+ * @param handler
+ * the handler to be added
+ */
+ public void addOnNotificationHandler(final OnNotificationHandler handler) {
+ if (handler != null && !onNotificationHandlers.contains(handler)) {
+ onNotificationHandlers.add(handler);
+ }
+ }
+
+ /**
+ *
+ * @param event
+ */
+ private void fireOnNotificationHandlers(final SuperfeedrEventExtension event) {
+ for (OnNotificationHandler handler : onNotificationHandlers) {
+ handler.onNotification(event);
+ }
+ }
+
+ /**
+ * this is a method responsible of parsing the received message and contruct
+ * the corresponding java object for dispatch
+ */
+ public void processPacket(final Packet packet) {
+ fireOnNotificationHandlers((SuperfeedrEventExtension) ((Message) packet).getExtension(SuperfeedrEventExtension.NAMESPACE));
+ }
+
+ /**
+ * Try to remove the specified handler from the list of notification handler
+ *
+ * @param handler
+ * the notification handler to be removed from the list
+ */
+ public void removeOnNotificationHandler(final OnNotificationHandler handler) {
+ onNotificationHandlers.remove(handler);
+ }
+}
View
40 src/org/superfeedr/extension/DefaultSuperfeerExtension.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+
+public class DefaultSuperfeerExtension implements PacketExtension{
+
+ public String getElementName() {
+ return null;
+ }
+
+ public String getNamespace() {
+ return null;
+ }
+
+ public String toXML() {
+ return null;
+ }
+
+}
View
101 src/org/superfeedr/extension/EntryExtension.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+import java.util.Date;
+
+public class EntryExtension extends DefaultSuperfeerExtension {
+ private String id;
+
+ private String link;
+
+ private String linkType;
+
+ private Date published;
+
+ private String summary;
+
+ private String title;
+
+ public EntryExtension(final String id2, final String link2, final String linkType2, final Date published2, final String title2,
+ final String summary2) {
+ this.id = id2;
+ this.link = link2;
+ this.linkType = linkType2;
+ this.published = published2;
+ this.title = title2;
+ this.summary = summary2;
+ }
+
+ /**
+ * The unique Id of this entry
+ *
+ * @return a String that represents the id of this entry
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * The link to the original information this entry represents
+ *
+ * @return a String that links to the original information
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * The Mime typ of the link to the original information this entry
+ * represents
+ */
+ public String getLinkType() {
+ return linkType;
+ }
+
+ /**
+ * The date the information has been published
+ *
+ * @return the published date
+ */
+ public Date getPublished() {
+ return published;
+ }
+
+ /**
+ * The Summary of this entry
+ *
+ * @return the summary
+ */
+ public String getSummary() {
+ return summary;
+ }
+
+ /**
+ * The title of this entry
+ *
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+}
View
49 src/org/superfeedr/extension/HttpExtension.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+
+public class HttpExtension extends DefaultSuperfeerExtension {
+
+ private String code;
+
+ private String info;
+
+ public HttpExtension(String code, String info) {
+ this.code = code;
+ this.info = info;
+ }
+
+ /**
+ * @return the code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @return the info
+ */
+ public String getInfo() {
+ return info;
+ }
+}
View
38 src/org/superfeedr/extension/ItemExtension.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+public class ItemExtension extends DefaultSuperfeerExtension{
+
+ private EntryExtension entryExtension;
+
+ public ItemExtension(EntryExtension entryExtension){
+ this.entryExtension = entryExtension;
+ }
+
+ /**
+ * @return the entry
+ */
+ public EntryExtension getEntry() {
+ return entryExtension;
+ }
+}
View
61 src/org/superfeedr/extension/ItemsExtension.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+import java.util.Iterator;
+import java.util.List;
+
+public class ItemsExtension extends DefaultSuperfeerExtension {
+
+ private String node;
+
+ private List<ItemExtension> items;
+
+ public ItemsExtension(String node, List<ItemExtension> items){
+ this.node = node;
+ this.items = items;
+ }
+
+ public Iterator<ItemExtension> getItems(){
+ return items == null ? new Iterator<ItemExtension>() {
+
+ public boolean hasNext() {
+ return false;
+ }
+
+ public ItemExtension next() {
+ return null;
+ }
+
+ public void remove() {
+ }
+ } : items.iterator();
+ }
+
+ public String getNode(){
+ return node;
+ }
+
+ public int getItemsCount() {
+ return items != null ? items.size() : 0;
+ }
+}
View
57 src/org/superfeedr/extension/StatusExtension.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+import java.util.Date;
+
+public class StatusExtension extends DefaultSuperfeerExtension {
+
+ private String feedURL;
+
+ private HttpExtension httpExtension;
+
+ private Date nextFetch;
+
+ public StatusExtension() {
+ }
+
+ public StatusExtension(final String feedURL, final Date nextFetch, HttpExtension extension){
+ this.feedURL = feedURL;
+ this.httpExtension = extension;
+ this.nextFetch = nextFetch;
+ }
+
+ public String getFeedURL(){
+ return feedURL;
+ }
+
+ /**
+ * @return the httpExtension
+ */
+ public HttpExtension getHttpExtension() {
+ return httpExtension;
+ }
+
+ public Date getNextFetch(){
+ return nextFetch;
+ }
+}
View
57 src/org/superfeedr/extension/SuperfeedrEventExtension.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.extension;
+
+public class SuperfeedrEventExtension extends DefaultSuperfeerExtension {
+
+ public static final String NAMESPACE = "http://jabber.org/protocol/pubsub#event";
+ public static final String ELEMENT_NAME = "event";
+
+ private StatusExtension status;
+
+ private ItemsExtension items;
+
+ @Override
+ public String getNamespace() {
+ return NAMESPACE;
+ }
+
+ @Override
+ public String getElementName() {
+ return ELEMENT_NAME;
+ }
+
+
+ public SuperfeedrEventExtension(StatusExtension status, ItemsExtension items) {
+ this.status = status;
+ this.items = items;
+ }
+
+ public StatusExtension getStatus(){
+ return status;
+ }
+
+ public ItemsExtension getItems(){
+ return items;
+ }
+
+}
View
66 src/org/superfeedr/provider/EmbeddedExtensionProvider.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.provider.PacketExtensionProvider;
+import org.jivesoftware.smack.util.PacketParserUtils;
+import org.xmlpull.v1.XmlPullParser;
+
+
+abstract public class EmbeddedExtensionProvider implements PacketExtensionProvider
+{
+
+ final public PacketExtension parseExtension(XmlPullParser parser) throws Exception
+ {
+ String namespace = parser.getNamespace();
+ String name = parser.getName();
+ Map<String, String> attMap = new HashMap<String, String>();
+
+ for(int i=0; i<parser.getAttributeCount(); i++)
+ {
+ attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
+ }
+ List<PacketExtension> extensions = new ArrayList<PacketExtension>();
+
+ do
+ {
+ int tag = parser.next();
+
+ if (tag == XmlPullParser.START_TAG){
+ String extensionName = parser.getName();
+ String extensionNamespace = parser.getNamespace();
+ extensions.add(PacketParserUtils.parsePacketExtension(extensionName, extensionNamespace, parser));
+ }
+
+ } while (!name.equals(parser.getName()));
+
+ return createReturnExtension(name, namespace, attMap, extensions);
+ }
+
+ abstract protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content);
+}
View
71 src/org/superfeedr/provider/EntryProvider.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.Date;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.provider.PacketExtensionProvider;
+import org.superfeedr.Superfeedr;
+import org.superfeedr.extension.EntryExtension;
+import org.xmlpull.v1.XmlPullParser;
+
+public class EntryProvider implements PacketExtensionProvider{
+
+ public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
+
+ String name = parser.getName();
+
+ String id = null;
+ String link = null;
+ String linkType = null;
+ Date published = null;
+ String summary = null;
+ String title = null;
+
+ int tag = parser.next();
+
+ while (!name.equals(parser.getName())){
+ if (tag == XmlPullParser.START_TAG){
+ if ("title".equals(parser.getName())){
+ parser.next();
+ title = parser.getText();
+ }else if ("summary".equals(parser.getName())){
+ parser.next();
+ summary = parser.getText();
+ }else if ("link".equals(parser.getName())){
+ link = parser.getAttributeValue(null, "href");
+ linkType = parser.getAttributeValue(null, "type");
+ }else if ("id".equals(parser.getName())){
+ parser.next();
+ id = parser.getText();
+ }else if ("published".equals(parser.getName())){
+ parser.next();
+ published = Superfeedr.convertDate(parser.getText());
+ }
+ }
+ tag = parser.next();
+ }
+ return new EntryExtension(id, link, linkType, published, title, summary);
+ }
+
+}
View
40 src/org/superfeedr/provider/EventProvider.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.superfeedr.extension.ItemsExtension;
+import org.superfeedr.extension.StatusExtension;
+import org.superfeedr.extension.SuperfeedrEventExtension;
+
+
+public class EventProvider extends EmbeddedExtensionProvider
+{
+ @Override
+ protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
+ {
+ return new SuperfeedrEventExtension((StatusExtension)content.get(0), (ItemsExtension)content.get(1));
+ }
+}
View
49 src/org/superfeedr/provider/HttpProvider.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.provider.PacketExtensionProvider;
+import org.superfeedr.extension.HttpExtension;
+import org.xmlpull.v1.XmlPullParser;
+
+public class HttpProvider implements PacketExtensionProvider{
+
+ public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
+
+ String extensionName = parser.getName();
+ String code = parser.getAttributeValue(null, "code");
+ String infos = null;
+
+ int currentTag = parser.next();
+ while (!extensionName.equals(parser.getName()) && currentTag != XmlPullParser.END_TAG){
+ if (currentTag == XmlPullParser.TEXT){
+ infos = parser.getText();
+ }
+
+ currentTag = parser.next();
+ }
+
+ return new HttpExtension(code, infos);
+ }
+
+}
View
41 src/org/superfeedr/provider/ItemProvider.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.superfeedr.extension.EntryExtension;
+import org.superfeedr.extension.ItemExtension;
+
+
+public class ItemProvider extends EmbeddedExtensionProvider
+{
+
+ @Override
+ protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap,
+ List<? extends PacketExtension> content) {
+ return new ItemExtension((EntryExtension)content.get(0));
+ }
+
+}
View
38 src/org/superfeedr/provider/ItemsProvider.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.superfeedr.extension.ItemExtension;
+import org.superfeedr.extension.ItemsExtension;
+
+public class ItemsProvider extends EmbeddedExtensionProvider
+{
+ protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
+ {
+ return new ItemsExtension(attributeMap.get("node"), (List<ItemExtension>)content);
+ }
+
+}
View
37 src/org/superfeedr/provider/NextFetchProvider.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import org.jivesoftware.smack.packet.DefaultPacketExtension;
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.provider.PacketExtensionProvider;
+import org.xmlpull.v1.XmlPullParser;
+
+public class NextFetchProvider implements PacketExtensionProvider{
+
+ public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
+ DefaultPacketExtension extension = new DefaultPacketExtension(parser.getName(), parser.getNamespace());
+ extension.setValue("next", parser.nextText());
+ return extension;
+ }
+
+}
View
43 src/org/superfeedr/provider/StatusProvider.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.provider;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jivesoftware.smack.packet.DefaultPacketExtension;
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.superfeedr.Superfeedr;
+import org.superfeedr.extension.HttpExtension;
+import org.superfeedr.extension.StatusExtension;
+
+public class StatusProvider extends EmbeddedExtensionProvider{
+
+ @Override
+ protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap,
+ List<? extends PacketExtension> content) {
+ String feedURL = attributeMap.get("feed");
+ DefaultPacketExtension nextFetch = ((DefaultPacketExtension)content.get(1));
+ return new StatusExtension(feedURL, Superfeedr.convertDate(nextFetch.getValue("next")), (HttpExtension)content.get(0));
+ }
+
+}
View
57 src/org/superfeedr/test/Test.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2009 julien
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.superfeedr.test;
+
+import java.util.Iterator;
+
+import org.jivesoftware.smack.XMPPConnection;
+import org.superfeedr.OnNotificationHandler;
+import org.superfeedr.Superfeedr;
+import org.superfeedr.extension.ItemExtension;
+import org.superfeedr.extension.SuperfeedrEventExtension;
+
+public class Test {
+ public static void main(final String[] args) throws Exception {
+ XMPPConnection.DEBUG_ENABLED = true;
+ Superfeedr feedr = new Superfeedr("thomas", "qwerty", "superfeedr.com");
+
+ feedr.addOnNotificationHandler(new OnNotificationHandler() {
+ public void onNotification(final SuperfeedrEventExtension event) {
+ System.err.println(event.getStatus().getFeedURL());
+ System.err.println(event.getStatus().getHttpExtension().getCode());
+ System.err.println(event.getStatus().getHttpExtension().getInfo());
+ if (event.getItems().getItemsCount() == 0) {
+ System.out.println("No items");
+ } else
+ for (Iterator<ItemExtension> iterator = event.getItems().getItems(); iterator.hasNext();) {
+ ItemExtension item = iterator.next();
+ System.out.println(item.getEntry().getTitle());
+ }
+ System.out.println("\n\n");
+ }
+ });
+
+ while (true) {
+ Thread.sleep(1000);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.