-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHunter.java
More file actions
94 lines (77 loc) · 1.91 KB
/
Hunter.java
File metadata and controls
94 lines (77 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Hunter, an internet search agent
// (c) Jimmy Larsson 1998
//
import java.net.*;
import java.util.*;
public final class Hunter
{
public static final int MAX_DOGS = 99;
public static final int MIN_DOGS = 2;
public static final int DEFAULT_DOGS = 8;
public final int noOfDogs = 15;
protected HunterStatistics stats;
protected UrlDB searchDB;
protected DogSearchExp searchExp;
protected HunterResult results;
protected Vector dogs;
protected Display display;
public Hunter ()
{
display = new Display ("Hunter", this);
}
public void startSearch (DogSearchExp srchExp, String startURL)
{
stats = new HunterStatistics (display);
UrlDB searchDB = new UrlDB (stats);
searchExp = srchExp;
results = new HunterResult ("HunterResults", stats);
// Add an URL to the DB, if startURL given
if (!startURL.equalsIgnoreCase(""))
{
try {
searchDB.add (new HunterUrl (new URL (startURL), 1));
} catch (MalformedURLException e1) {
return;
}
}
// Fire up some Dogs
Dog.noOfDogs = 0;
dogs = new Vector ();
for (int i = 0; i < noOfDogs; i++)
dogs.addElement(new Dog (searchDB, searchExp, results, stats));
stats.setHunterStatus ("Searching...");
}
public void stopSearch ()
{
if (stats != null)
stats.setHunterStatus ("Stopping...");
for (Enumeration e = dogs.elements(); e.hasMoreElements();)
{
((Dog) e.nextElement()).signalStop();
}
}
// Generate results so far
public void dumpResults ()
{
results.dumpTempResults ();
// should launch netscape here
}
// Quit
public void quit ()
{
// No nice quitting here... just brake it all off!
System.exit(0);
}
// MAIN
public static void main (String[] args)
{
Hunter hunter = new Hunter ();
// Wait until all dogs are done
while (Dog.noOfDogs() > 0)
{
Thread.yield ();
}
return;
}
}