01: package net.matuschek.spider;
02:
03: /*********************************************
04: Copyright (c) 2001 by Daniel Matuschek
05: *********************************************/
06:
07: /**
08: * <p>The TaskList is a generic interface for a storage for RobotTask
09: * objects. It will be used by the WebRobot for the queue and the list
10: * of visited URLs.</p>
11: * <p>It implements many methods from the Collection API, but will
12: * only be used to store RobotTask objects.</p>
13: * <p>Implementation could store the list in the memory, in a file or
14: * even in an SQL database. For lookups it may be useful that the RobotTask
15: * implements the hashCode() method.</p>
16: * <p><b>Implementations should be thread-safe or must note that they are
17: * nopt thread safe !</b></p>
18: *
19: * @author Daniel Matuschek
20: * @version $Id: TaskList.java,v 1.3 2002/05/31 14:45:56 matuschd Exp $
21: */
22: public interface TaskList {
23:
24: /**
25: * Add a task to the end of the list
26: * @param task a RobotTask object to store in the queue
27: */
28: void add(RobotTask task);
29:
30: /**
31: * Add a task at the beginning of list
32: * @param task a RobotTask object to store in the queue
33: */
34: void addAtStart(RobotTask task);
35:
36: /**
37: * Clean up the list, remove all objects
38: */
39: void clear();
40:
41: /**
42: * Is this robot task stored in the list ?
43: * @param task a RobotTask object to lookup
44: * @return true if there is a RobotTask in the list that is equal to
45: * the given task using the equals() method
46: */
47: boolean contains(RobotTask task);
48:
49: /**
50: * Remove this object from the list
51: * @param task the RobotTaks to remove
52: * @return the object was found and removed, false if it
53: * was not in the list
54: */
55: boolean remove(RobotTask task);
56:
57: /**
58: * Get and remove the first element.
59: * @return the first task in the list. This object will also be removed
60: * from the list.
61: */
62: RobotTask removeFirst();
63:
64: /**
65: * Returns the number of elements in this list
66: */
67: int size();
68:
69: /**
70: * Get the n-th element in the list. Elements are numbered form 0 to
71: * size-1.
72: * @param position
73: */
74: RobotTask elementAt(int position);
75:
76: }
|