01: /*
02: * Copyright 2005 by Lars Torunski
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17: package com.torunski.crawler.filter;
18:
19: /**
20: * A ILinkFilter that filters URIs for a special server only.
21: *
22: * @author Lars Torunski
23: * @version $Revision: 1.4 $
24: */
25: public class ServerFilter implements ILinkFilter {
26:
27: /** The specified server to filter for */
28: private String server;
29:
30: /**
31: * Constructor for ServerFilter.
32: *
33: * @param server the server to filter for.
34: */
35: public ServerFilter(String server) {
36: this .server = server;
37: }
38:
39: /**
40: * Filters links which was specified in the constructor, only these would be filtered.
41: *
42: * @see com.torunski.crawler.filter.ILinkFilter#accept(java.lang.String, java.lang.String)
43: */
44: public boolean accept(String origin, String link) {
45: return (link != null) && (link.startsWith(server));
46: }
47:
48: }
|