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.model;
18:
19: import java.util.Collection;
20: import java.util.NoSuchElementException;
21:
22: import com.torunski.crawler.link.Link;
23:
24: /**
25: * Defines the methods for the crawler model.
26: *
27: * @author Lars Torunski
28: * @version $Revision: 1.6 $
29: */
30: public interface ICrawlerModel {
31:
32: /**
33: * Returns <tt>true</tt> if the crawler model has no more links. (In other
34: * words, returns <tt>false</tt> if <tt>pop</tt> would return an element
35: * rather than throwing an exception.)
36: *
37: * @return <tt>true</tt> if the crawler model has no more links.
38: */
39: boolean isEmpty();
40:
41: /**
42: * Returns the next link in the crawler model. The method removes
43: * the link from the to visit list and adds the link to the visited list.
44: *
45: * @return the next link in the crawler model.
46: * @exception NoSuchElementException crawler model has no more elements.
47: */
48: Link pop();
49:
50: /**
51: * Adds a <b>new</b> URI to the to be visted URIs.
52: * @param origin the origin link of the new URI
53: * @param uri adds a new link with the URI to the crawler model.
54: */
55: void add(Link origin, String uri);
56:
57: /**
58: * Adds <b>new</b> URIs to the to be visited URIs.
59: * @param origin the origin link of the new URI
60: * @param uri adds new links with the URIs (in the collection) to the crawler model.
61: */
62: void add(Link origin, Collection uri);
63:
64: /**
65: * Creates a <b>new</b> link based on the orginUri and uri parameter.
66: * @param originUri the origin URI of the link
67: * @param uri the new URI
68: */
69: Link createLink(String originUri, String uri);
70:
71: /**
72: * @return a object set of visited URIs.
73: */
74: Collection getVisitedURIs();
75:
76: /**
77: * @return a object set of still to be visited URIs.
78: */
79: Collection getToVisitURIs();
80:
81: }
|