KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > matuschek > spider > TaskList


1 package net.matuschek.spider;
2
3 /*********************************************
4     Copyright (c) 2001 by Daniel Matuschek
5  *********************************************/

6
7
8 /**
9  * <p>The TaskList is a generic interface for a storage for RobotTask
10  * objects. It will be used by the WebRobot for the queue and the list
11  * of visited URLs.</p>
12  * <p>It implements many methods from the Collection API, but will
13  * only be used to store RobotTask objects.</p>
14  * <p>Implementation could store the list in the memory, in a file or
15  * even in an SQL database. For lookups it may be useful that the RobotTask
16  * implements the hashCode() method.</p>
17  * <p><b>Implementations should be thread-safe or must note that they are
18  * nopt thread safe !</b></p>
19  *
20  * @author Daniel Matuschek
21  * @version $Id: TaskList.java,v 1.3 2002/05/31 14:45:56 matuschd Exp $
22  */

23 public interface TaskList {
24
25   /**
26    * Add a task to the end of the list
27    * @param task a RobotTask object to store in the queue
28    */

29   void add(RobotTask task);
30
31   /**
32    * Add a task at the beginning of list
33    * @param task a RobotTask object to store in the queue
34    */

35   void addAtStart(RobotTask task);
36
37
38   /**
39    * Clean up the list, remove all objects
40    */

41   void clear();
42
43
44   /**
45    * Is this robot task stored in the list ?
46    * @param task a RobotTask object to lookup
47    * @return true if there is a RobotTask in the list that is equal to
48    * the given task using the equals() method
49    */

50   boolean contains(RobotTask task);
51
52
53   /**
54    * Remove this object from the list
55    * @param task the RobotTaks to remove
56    * @return the object was found and removed, false if it
57    * was not in the list
58    */

59   boolean remove(RobotTask task);
60
61
62   /**
63    * Get and remove the first element.
64    * @return the first task in the list. This object will also be removed
65    * from the list.
66    */

67   RobotTask removeFirst();
68
69   
70   /**
71    * Returns the number of elements in this list
72    */

73   int size();
74
75
76   /**
77    * Get the n-th element in the list. Elements are numbered form 0 to
78    * size-1.
79    * @param position
80    */

81   RobotTask elementAt(int position);
82
83 }
84
Popular Tags