abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1174413 - /abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
Date Thu, 22 Sep 2011 22:08:37 GMT
Author: jmsnell
Date: Thu Sep 22 22:08:36 2011
New Revision: 1174413

URL: http://svn.apache.org/viewvc?rev=1174413&view=rev
Log:
simple utility collectionwriter impl

Added:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
  (with props)

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java?rev=1174413&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
(added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
Thu Sep 22 22:08:36 2011
@@ -0,0 +1,50 @@
+package org.apache.abdera2.activities.extra;
+
+import org.apache.abdera2.activities.model.ASBase;
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.CollectionWriter;
+import org.apache.abdera2.common.pusher.Pusher;
+
+/**
+ * Simple CollectionWriter implemention that wraps a Pusher object. 
+ * Calls to writeObject/writeObjects are sent through to the pusher.push 
+ * and pusher.pushAll methods. The writeHeader and complete methods are 
+ * ignored.
+ */
+public class PusherCollectionWriter 
+  implements CollectionWriter {
+
+  private final Pusher<ASObject> pusher;
+  
+  public PusherCollectionWriter(Pusher<ASObject> pusher) {
+    this.pusher = pusher;
+  }
+
+  /**
+   * Ignored in this implementation
+   */
+  public void writeHeader(ASBase base) {
+    // We ignore this in the pusher...
+  }
+
+  public void writeObject(ASObject object) {
+    pusher.push(object);
+  }
+
+  public void writeObjects(ASObject... objects) {
+    for (ASObject object : objects)
+      pusher.push(object);
+  }
+
+  public void writeObjects(Iterable<ASObject> objects) {
+    pusher.pushAll(objects);
+  }
+
+  /**
+   * Ignored by this implementation
+   */
+  public void complete() {
+    // ignored
+  }
+  
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/PusherCollectionWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message