You are viewing a plain text version of this content. The canonical link for it is here.
Posted to droids-commits@incubator.apache.org by to...@apache.org on 2013/01/31 16:25:06 UTC

svn commit: r1441044 - in /incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core: AbstractDroid.java ContentEntity.java Fetcher.java LinkedTask.java SimpleTaskQueueWithHistory.java TaskMaster.java

Author: tobr
Date: Thu Jan 31 16:25:06 2013
New Revision: 1441044

URL: http://svn.apache.org/viewvc?rev=1441044&view=rev
Log:
added convenience methods to ContentEntity
added javadocs

Modified:
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Fetcher.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/LinkedTask.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java Thu Jan 31 16:25:06 2013
@@ -31,6 +31,8 @@ import java.util.concurrent.TimeUnit;
 
 /**
  * Manage common tasks in standard Droids
+ *
+ * @version 1.0
  */
 public abstract class AbstractDroid<T extends Task> implements Droid<T> {
     protected final Queue<T> queue;

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java Thu Jan 31 16:25:06 2013
@@ -26,6 +26,8 @@ import java.util.Set;
  * ContentEntity stores the data of the retrieved content in a Map.
  * The predefined members are shortcuts to default fields.
  * Otherwise you can put your meta data in the Map using your own key.
+ *
+ * @version 1.0
  */
 public class ContentEntity {
     private Map<String, Object> data;
@@ -90,12 +92,24 @@ public class ContentEntity {
     }
 
     /**
+     * Close the content stream to release resources.
+     *
+     * @throws DroidsException
+     * @throws IOException
+     */
+    public void close() throws DroidsException, IOException {
+        if (this.getContent() != null) {
+            this.getContent().close();
+        }
+    }
+
+    /**
      * TODO should this go to the {@see LinkedTask}
      *
      * Outgoing links from the current document.
      *
-     * @param links
-     * @param <T>
+     * @param links a set of links
+     * @param <T> the Task
      */
     public <T extends Task> void setLinks(Set<T> links) {
         this.put(LINKS, links);
@@ -104,7 +118,7 @@ public class ContentEntity {
     /**
      * Returns the Set of tasks, defining the outgoing links.
      *
-     * @param <T>
+     * @param <T> the Task
      * @return a set of tasks
      * @throws DroidsException
      */
@@ -121,24 +135,49 @@ public class ContentEntity {
     }
 
     /**
-     * Returns the data map.
+     * Set the content type of the document.
      *
-     * @return map containing the data
+     * @param contentType the content type
      */
-    public Map<String, Object> getData() {
-        return data;
+    public void setContentType(String contentType) {
+        this.put(CONTENT_TYPE, contentType);
     }
 
     /**
-     * Close the content stream to release resources.
+     * Get the content type.
      *
-     * @throws DroidsException
-     * @throws IOException
+     * @return the content type
      */
-    public void close() throws DroidsException, IOException {
-        if (this.getContent() != null) {
-            this.getContent().close();
-        }
+    public String getContentType() {
+        return this.getValue(CONTENT_TYPE).toString();
+    }
+
+    /**
+     * Set the content length
+     *
+     * @param contentLength the length of the content
+     */
+    public void setContentLength(long contentLength) {
+        this.put(CONTENT_LENGTH, contentLength);
+    }
+
+    /**
+     * Get the content length.
+     *
+     * @return the length of the content.
+     */
+    public long getContentLength() {
+        return Long.getLong(this.getValue(CONTENT_LENGTH).toString()).longValue();
     }
 
+    /**
+     * Returns the data map.
+     *
+     * @return map containing the data
+     */
+    public Map<String, Object> getData() {
+        return data;
+    }
+
+
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Fetcher.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Fetcher.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Fetcher.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Fetcher.java Thu Jan 31 16:25:06 2013
@@ -20,8 +20,7 @@ import java.io.IOException;
 
 
 /**
- * The protocol interface is a wrapper to hide the underlying implementation of
- * the communication at protocol level.
+ * The fetcher interface can be used to retrieve the content of the task.
  *
  * @version 1.0
  */

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/LinkedTask.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/LinkedTask.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/LinkedTask.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/LinkedTask.java Thu Jan 31 16:25:06 2013
@@ -25,8 +25,8 @@ import org.apache.droids.core.Task;
 
 
 /**
- * Simple extension of a {@link Task}. Adding from/to link, anchor text
- * and the last modified attribute to the task object.
+ * Simple extension of a {@link Task}. Adding from/to link
+ * to the task object.
  *
  * @version 1.0
  */

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java Thu Jan 31 16:25:06 2013
@@ -26,6 +26,8 @@ import java.util.concurrent.LinkedBlocki
 
 /**
  * Extend the task queue to ignore any tasks we have already seen
+ *
+ * @version 1.0
  */
 public class SimpleTaskQueueWithHistory<T extends Task> extends LinkedBlockingQueue<T> {
 

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java?rev=1441044&r1=1441043&r2=1441044&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java Thu Jan 31 16:25:06 2013
@@ -25,6 +25,8 @@ import org.apache.droids.exception.TaskE
 
 /**
  * A TaskMaster is responsible for running all the tasks.
+ *
+ * @version 1.0
  */
 public interface TaskMaster<T extends Task> {
     /**