source: trunk/src/org/expeditee/agents/SearchFramesetFast.java@ 313

Last change on this file since 313 was 313, checked in by ra33, 16 years ago

Added more features to the Greenstone Search

File size: 1.4 KB
Line 
1package org.expeditee.agents;
2
3import java.util.Collection;
4
5import org.expeditee.gui.Frame;
6import org.expeditee.gui.FrameGraphics;
7import org.expeditee.gui.FrameIO;
8
9public class SearchFramesetFast extends SearchAgent {
10 private long _firstFrame = 1;
11
12 private long _maxFrame = Integer.MAX_VALUE;
13
14 public SearchFramesetFast(long firstFrame, long maxFrame, String searchText) {
15 this(searchText);
16 _firstFrame = firstFrame;
17 _maxFrame = maxFrame;
18 }
19
20 public SearchFramesetFast(String searchText) {
21 super(searchText);
22 }
23
24 @Override
25 protected Frame process(Frame frame) {
26 if(frame == null) {
27 frame = FrameIO.LoadFrame(_startName + '0');
28 }
29 String path = frame.getPath();
30
31 int count = FrameIO.getLastNumber(_startName);
32 for (long i = _firstFrame;i <= _maxFrame && i <= count; i++) {
33 if (_stop) {
34 break;
35 }
36 String frameName = _startName + i;
37 overwriteMessage("Searching " + frameName);
38 Collection<String> found = FrameIO.searchFrame(frameName, _pattern, path);
39 int size = found == null? 0 :found.size();
40 // If the frame exists
41 if(found != null)
42 _frameCount++;
43 if(size > 0){
44 String repeats = size > 1? ("("+ size+ ")") : "";
45 _results.addText(frameName + repeats, null, frameName, null, false);
46 FrameGraphics.requestRefresh(true);
47 }
48 }
49 _results.save();
50
51 String resultFrameName = _results.getName();
52 if (_clicked != null)
53 _clicked.setLink(resultFrameName);
54
55 return _results.getFirstFrame();
56 }
57}
Note: See TracBrowser for help on using the repository browser.