Author: tobr
Date: Thu Jan 31 16:09:23 2013
New Revision: 1441038
URL: http://svn.apache.org/viewvc?rev=1441038&view=rev
Log:
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
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=1441038&r1=1441037&r2=1441038&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:09:23 2013
@@ -42,10 +42,19 @@ public abstract class AbstractDroid<T ex
protected final static Logger logger =
LoggerFactory.getLogger(AbstractDroid.class);
+ /**
+ * Constructor with default implementations for queue and taskmaster.
+ */
public AbstractDroid() {
this(null, null);
}
+ /**
+ * Constructor using the user choice for queue and taskmaster
+ *
+ * @param queue the queue to store the tasks
+ * @param taskMaster the
+ */
public AbstractDroid(Queue<T> queue, TaskMaster<T> taskMaster) {
this.queue = queue == null ? new SimpleTaskQueueWithHistory<T>() :
queue;
this.taskMaster = queue == null ? new MultiThreadedTaskMaster<T>() :
taskMaster;
@@ -54,6 +63,52 @@ public abstract class AbstractDroid<T ex
this.handlerFactory = new HandlerFactory();
}
+ /**
+ * Fetcher for retrieving the content of a task.
+ *
+ * @param fetcher the fetcher
+ */
+ public void setFetcher(Fetcher fetcher) {
+ this.fetcher = fetcher;
+ }
+
+ /**
+ * Add one or multiple Parsers to an internal parser factory
+ * to parse the tasks.
+ *
+ * @param parsers Parser implementations
+ */
+ public void addParsers(Parser... parsers) {
+ for (Parser parser : parsers) {
+ this.parserFactory.addParser(parser);
+ }
+ }
+
+ /**
+ * Add one or multiple handlers to an internal handler factory
+ * to handle the tasks.
+ *
+ * @param handlers Handler implementations
+ */
+ public void addHandlers(Handler... handlers) {
+ for (Handler handler : handlers) {
+ this.handlerFactory.addHandler(handler);
+ }
+ }
+
+ /**
+ * Add one or multiple filters to an internal filter factory
+ * to filter the tasks
+ *
+ * @param filters Filter implementations
+ */
+ public void addFilters(Filter<T>... filters) {
+ for (Filter<T> filter : filters) {
+ this.filterFactory.addFilter(filter);
+ }
+ }
+
+
@Override
public void start() {
taskMaster.start(queue, this);
@@ -110,25 +165,4 @@ public abstract class AbstractDroid<T ex
logger.debug("finished task: " + task.getURI());
}
- public void setFetcher(Fetcher fetcher) {
- this.fetcher = fetcher;
- }
-
- public void addParsers(Parser... parsers) {
- for (Parser parser : parsers) {
- this.parserFactory.addParser(parser);
- }
- }
-
- public void addHandlers(Handler... handlers) {
- for (Handler handler : handlers) {
- this.handlerFactory.addHandler(handler);
- }
- }
-
- public void addFilters(Filter<T>... filters) {
- for (Filter<T> filter : filters) {
- this.filterFactory.addFilter(filter);
- }
- }
}
\ No newline at end of file
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=1441038&r1=1441037&r2=1441038&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:09:23 2013
@@ -23,9 +23,9 @@ import java.util.Map;
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.
*/
public class ContentEntity {
private Map<String, Object> data;
@@ -35,26 +35,48 @@ public class ContentEntity {
public final static String CONTENT_LENGTH = "content-length";
public final static String LINKS = "links";
+ /**
+ * Constructor
+ */
public ContentEntity() {
this.data = new HashMap<String, Object>();
}
- public Object getValue(String key) {
- return data.get(key);
- }
-
+ /**
+ * Put something in the data map.
+ *
+ * @param key the key to store the data
+ * @param value the value for the key
+ */
public void put(String key, Object value) {
this.data.put(key, value);
}
- public void setContent(InputStream in) {
- this.put(CONTENT, in);
+ /**
+ * Getting the value stored under a key
+ *
+ * @param key the key to the value
+ * @return object with the value
+ */
+ public Object getValue(String key) {
+ return data.get(key);
}
- public <T extends Task> void setLinks(Set<T> links) {
- this.put(LINKS, links);
+ /**
+ * Set the content data.
+ *
+ * @param in the content data
+ */
+ public void setContent(InputStream in) {
+ this.put(CONTENT, in);
}
+ /**
+ * Get the content data.
+ *
+ * @return an InputStream containing the data of the content
+ * @throws DroidsException
+ */
public InputStream getContent() throws DroidsException {
if (this.getValue(CONTENT) != null) {
if (this.getValue(CONTENT) instanceof InputStream) {
@@ -67,6 +89,25 @@ public class ContentEntity {
}
}
+ /**
+ * TODO should this go to the {@see LinkedTask}
+ *
+ * Outgoing links from the current document.
+ *
+ * @param links
+ * @param <T>
+ */
+ public <T extends Task> void setLinks(Set<T> links) {
+ this.put(LINKS, links);
+ }
+
+ /**
+ * Returns the Set of tasks, defining the outgoing links.
+ *
+ * @param <T>
+ * @return a set of tasks
+ * @throws DroidsException
+ */
public <T extends Task> Set<T> getLinks() throws DroidsException {
if (this.getValue(LINKS) != null) {
if (this.getValue(LINKS) instanceof Set) {
@@ -79,10 +120,21 @@ public class ContentEntity {
}
}
+ /**
+ * Returns the data map.
+ *
+ * @return map containing the data
+ */
public Map<String, Object> getData() {
return data;
}
+ /**
+ * Close the content stream to release resources.
+ *
+ * @throws DroidsException
+ * @throws IOException
+ */
public void close() throws DroidsException, IOException {
if (this.getContent() != null) {
this.getContent().close();