org.apache.droids.impl
Class SimpleTaskQueue<T extends Task>

java.lang.Object
  extended by org.apache.droids.impl.SimpleTaskQueue<T>
All Implemented Interfaces:
TaskQueue<T>, TaskValidator<T>
Direct Known Subclasses:
SimpleTaskQueueWithHistory

public class SimpleTaskQueue<T extends Task>
extends java.lang.Object
implements TaskQueue<T>, TaskValidator<T>

A simple


Constructor Summary
SimpleTaskQueue()
          Simple queue constructor.
SimpleTaskQueue(java.util.Queue queue)
           
 
Method Summary
 void clear()
           
 int getMaxSize()
           
 int getSize()
          How many task do we have left in the queue.
 T getTask(java.lang.String id)
          Return the task that is identified with the given id
 TaskValidator<T> getTaskValidator()
           
 boolean hasNext()
          Do we have more task waiting for service
 void merge(java.util.Collection<? extends T> tasks)
          Tasks with duplicate keys will be overwritten
 void merge(T task)
          Add a Task to the queue...
 T next()
          Return the next task that is waiting for service
 java.util.Collection<? extends T> peek(int size)
          Get the top 'size' elements in the queue
 void setMaxSize(int maxSize)
           
 void setTaskValidator(TaskValidator<T> taskValidator)
           
 T validateTask(T task)
          This will take a task and make sure it is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTaskQueue

public SimpleTaskQueue()
Simple queue constructor.


SimpleTaskQueue

public SimpleTaskQueue(java.util.Queue queue)
Method Detail

getTask

public T getTask(java.lang.String id)
Description copied from interface: TaskQueue
Return the task that is identified with the given id

Specified by:
getTask in interface TaskQueue<T extends Task>
Parameters:
id - of the task we want
Returns:
the task idenfied by the given id

getSize

public int getSize()
Description copied from interface: TaskQueue
How many task do we have left in the queue.

Specified by:
getSize in interface TaskQueue<T extends Task>
Returns:
number of tasks do we have left in the queue.

hasNext

public boolean hasNext()
Description copied from interface: TaskQueue
Do we have more task waiting for service

Specified by:
hasNext in interface TaskQueue<T extends Task>
Returns:
true if we have. false otherwise

merge

public void merge(T task)
           throws InvalidTaskException
Description copied from interface: TaskQueue
Add a Task to the queue...

Specified by:
merge in interface TaskQueue<T extends Task>
Parameters:
task - task to add to the Queue
Throws:
InvalidTaskException

merge

public void merge(java.util.Collection<? extends T> tasks)
           throws InvalidTaskException
Tasks with duplicate keys will be overwritten

Specified by:
merge in interface TaskQueue<T extends Task>
Parameters:
tasks - the list of task that we want to add to the queue
Throws:
InvalidTaskException

next

public T next()
Description copied from interface: TaskQueue
Return the next task that is waiting for service

Specified by:
next in interface TaskQueue<T extends Task>
Returns:
next task in line.

clear

public void clear()

validateTask

public T validateTask(T task)
                            throws InvalidTaskException
Description copied from interface: TaskValidator
This will take a task and make sure it is valid. It may modify the task so it is valid. For example, a URL may be normalized within the validateTask method.

Specified by:
validateTask in interface TaskValidator<T extends Task>
Throws:
InvalidTaskException

getTaskValidator

public TaskValidator<T> getTaskValidator()

setTaskValidator

public void setTaskValidator(TaskValidator<T> taskValidator)

getMaxSize

public int getMaxSize()

setMaxSize

public void setMaxSize(int maxSize)

peek

public java.util.Collection<? extends T> peek(int size)
Description copied from interface: TaskQueue
Get the top 'size' elements in the queue

Specified by:
peek in interface TaskQueue<T extends Task>


Copyright © 2007-2009. All Rights Reserved.