1 | /**
|
---|
2 | * SearchFrameset.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.agents;
|
---|
20 |
|
---|
21 | import java.util.Collection;
|
---|
22 |
|
---|
23 | import org.expeditee.gui.Frame;
|
---|
24 | import org.expeditee.gui.FrameIO;
|
---|
25 |
|
---|
26 | public class SearchFrameset extends SearchAgent {
|
---|
27 | private long _firstFrame = 1;
|
---|
28 |
|
---|
29 | private long _maxFrame = Integer.MAX_VALUE;
|
---|
30 |
|
---|
31 | public SearchFrameset(long firstFrame, long maxFrame, String searchText) {
|
---|
32 | this(searchText);
|
---|
33 | _firstFrame = firstFrame;
|
---|
34 | _maxFrame = maxFrame;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public SearchFrameset(String searchText) {
|
---|
38 | super(searchText);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | protected Frame process(Frame frame) {
|
---|
43 | if (frame == null) {
|
---|
44 | frame = FrameIO.LoadFrame(_startName + '0');
|
---|
45 | }
|
---|
46 | String path = frame.getPath();
|
---|
47 |
|
---|
48 | int count = FrameIO.getLastNumber(_startName);
|
---|
49 | for (long i = _firstFrame; i <= _maxFrame && i <= count; i++) {
|
---|
50 | if (_stop) {
|
---|
51 | break;
|
---|
52 | }
|
---|
53 | String frameName = _startName + i;
|
---|
54 | overwriteMessage("Searching " + frameName);
|
---|
55 | Collection<String> found = FrameIO.searchFrame(frameName, _pattern,
|
---|
56 | path);
|
---|
57 | addResults(i + "", frameName, found);
|
---|
58 | }
|
---|
59 | _results.save();
|
---|
60 |
|
---|
61 | String resultFrameName = _results.getName();
|
---|
62 | if (_clicked != null)
|
---|
63 | _clicked.setLink(resultFrameName);
|
---|
64 |
|
---|
65 | return _results.getFirstFrame();
|
---|
66 | }
|
---|
67 | }
|
---|