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

Last change on this file since 284 was 176, checked in by ra33, 16 years ago
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) {
15 _firstFrame = firstFrame;
16 _maxFrame = maxFrame;
17 }
18
19 public SearchFramesetFast() {
20 super();
21 }
22
23 @Override
24 protected Frame process(Frame frame) {
25 if(frame == null) {
26 frame = FrameIO.LoadFrame(_startName + '0');
27 }
28 String path = frame.path;
29
30 int count = FrameIO.getLastNumber(_startName);
31 for (long i = _firstFrame;i <= _maxFrame && i < count; i++) {
32 if (_stop) {
33 break;
34 }
35 String frameName = _startName + i;
36 overwriteMessage("Searching " + frameName);
37 Collection<String> found = FrameIO.searchFrame(frameName, _pattern, path);
38 int size = found == null? 0 :found.size();
39 // If the frame exists
40 if(found != null)
41 _frameCount++;
42 if(size > 0){
43 String repeats = size > 1? ("("+ size+ ")") : "";
44 _results.addText(frameName + repeats, null, frameName, null, false);
45 FrameGraphics.requestRefresh(true);
46 }
47 }
48 _results.save();
49
50 String resultFrameName = _results.getName();
51 if (_clicked != null)
52 _clicked.setLink(resultFrameName);
53
54 return _results.getFirstFrame();
55 }
56}
Note: See TracBrowser for help on using the repository browser.