1 | /**
|
---|
2 | * SearchFramesetAndReplace.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 org.expeditee.gui.Frame;
|
---|
22 | import org.expeditee.gui.FrameIO;
|
---|
23 |
|
---|
24 | public class SearchFramesetAndReplace extends SearchAgent {
|
---|
25 | private long _firstFrame = 1;
|
---|
26 | private long _maxFrame = Integer.MAX_VALUE;
|
---|
27 |
|
---|
28 | public SearchFramesetAndReplace(long firstFrame, long maxFrame, String searchText) {
|
---|
29 | this(searchText);
|
---|
30 | _firstFrame = firstFrame;
|
---|
31 | _maxFrame = maxFrame;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public SearchFramesetAndReplace(String searchText) {
|
---|
35 | super(searchText);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | protected Frame process(Frame frame) {
|
---|
40 | int count = FrameIO.getLastNumber(_startName);
|
---|
41 | for (long i = _firstFrame;i <= _maxFrame && i <= count; i++) {
|
---|
42 | if (_stop) {
|
---|
43 | break;
|
---|
44 | }
|
---|
45 | String frameName = _startName + i;
|
---|
46 | overwriteMessage("Searching " + frameName);
|
---|
47 | if(searchFrame(_results, frameName, _pattern,
|
---|
48 | _replacementString))
|
---|
49 | _frameCount++;
|
---|
50 | }
|
---|
51 | _results.save();
|
---|
52 |
|
---|
53 | String resultFrameName = _results.getName();
|
---|
54 | if (_clicked != null)
|
---|
55 | _clicked.setLink(resultFrameName);
|
---|
56 |
|
---|
57 | return _results.getFirstFrame();
|
---|
58 | }
|
---|
59 | }
|
---|