1 /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright 2008 Ledermueller Achim
4 * serc is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
19 import java
.util
.Vector
;
23 public Vector
<Result
> urlsSe1
;
24 public Vector
<Result
> urlsSe2
;
25 public Vector
<URL
> domains
;
26 public Vector
<URL
> files
;
27 private static String
[] path
;
31 urlsSe1
= new Vector
<Result
>();
32 urlsSe2
= new Vector
<Result
>();
33 domains
= new Vector
<URL
>();
34 files
= new Vector
<URL
>();
37 public void compare(ResultSet r1
, ResultSet r2
) {
38 for(int i
=0; i
<r1
.results
.size(); i
++) {
39 for(int j
=0; j
<r1
.results
.get(i
).urls
.size(); j
++) {
40 for(int k
=0; k
<r2
.results
.size(); k
++) {
41 for(int l
=0; l
<r2
.results
.get(k
).urls
.size(); l
++) {
42 if(r1
.results
.get(i
).urls
.get(j
).equals(r2
.results
.get(k
).urls
.get(l
))) {
43 if(r1
.results
.get(i
).getRelevantUrl() == null) {
45 r1
.results
.get(i
).setRelevantUrl(r1
.results
.get(i
).urls
.get(j
));
46 r2
.results
.get(k
).setRelevantUrl(r2
.results
.get(k
).urls
.get(l
));
48 urlsSe1
.add(r1
.results
.get(i
));
49 urlsSe2
.add(r2
.results
.get(k
));
51 } else if( !Resolver
.getFilename( r1
.results
.get(i
).urls
.get(j
)).equals("") &&
52 Resolver
.getFilename(r1
.results
.get(i
).urls
.get(j
)).equals(Resolver
.getFilename(r2
.results
.get(k
).urls
.get(l
)))
55 files
.add(r1
.results
.get(i
).urls
.get(j
));
56 files
.add(r2
.results
.get(k
).urls
.get(l
));
58 } else if(r1
.results
.get(i
).urls
.get(j
).getHost().equals(r2
.results
.get(k
).urls
.get(l
).getHost())) {
59 domains
.add(r1
.results
.get(i
).urls
.get(j
));
60 domains
.add(r2
.results
.get(k
).urls
.get(l
));
68 public static String
getFilename(URL url
) {
69 if(url
.getFile().charAt(url
.getFile().length()-1) == '/')
72 path
= url
.getFile().split("/");
76 return path
[path
.length
-1];
79 public String
urlsToString() {
81 //for(int i=0;i<urls.size();i++){
82 // str += urls.get(i).toString() + "\n";
86 public String
domainsToString() {
88 for(int i
=0;i
<domains
.size();i
++){
89 str
+= domains
.get(i
) + "\n";
93 public String
filesToString() {
95 for(int i
=0;i
<files
.size();i
++){
96 str
+= files
.get(i
) + "\n";