KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > archive > crawler > admin > SeedRecord


1 /* SeedRecord
2  *
3  * $Id: SeedRecord.java,v 1.3.4.1 2007/01/13 01:31:07 stack-sf Exp $
4  *
5  * Created on June 12, 2005
6  *
7  * Copyright (C) 2005 Internet Archive.
8  *
9  * This file is part of the Heritrix web crawler (crawler.archive.org).
10  *
11  * Heritrix is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * any later version.
15  *
16  * Heritrix is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser Public License
22  * along with Heritrix; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  */

26 package org.archive.crawler.admin;
27
28 import java.io.Serializable JavaDoc;
29
30 import org.archive.crawler.datamodel.CandidateURI;
31 import org.archive.crawler.datamodel.CoreAttributeConstants;
32 import org.archive.crawler.datamodel.CrawlURI;
33
34 /**
35  * Record of all interesting info about the most-recent
36  * processing of a specific seed.
37  *
38  * @author gojomo
39  */

40 public class SeedRecord implements CoreAttributeConstants, Serializable JavaDoc {
41     private static final long serialVersionUID = -8455358640509744478L;
42     private final String JavaDoc uri;
43     private int statusCode;
44     private final String JavaDoc disposition;
45     private String JavaDoc redirectUri;
46     
47     /**
48      * Create a record from the given CrawlURI and disposition string
49      *
50      * @param curi CrawlURI, already processed as reported to StatisticsTracker
51      * @param disposition descriptive disposition string
52      *
53      */

54     public SeedRecord(CrawlURI curi, String JavaDoc disposition) {
55         super();
56         this.uri = curi.toString();
57         this.statusCode = curi.getFetchStatus();
58         this.disposition = disposition;
59         if (statusCode==301 || statusCode == 302) {
60             for (CandidateURI cauri: curi.getOutCandidates()) {
61                 if("location:".equalsIgnoreCase(cauri.getViaContext().
62                         toString())) {
63                     redirectUri = cauri.toString();
64                 }
65             }
66         }
67     }
68     
69     /**
70      * Constructor for when a CrawlURI is unavailable; such
71      * as when considering seeds not yet passed through as
72      * CrawlURIs.
73      *
74      * @param uri
75      * @param disposition
76      */

77     public SeedRecord(String JavaDoc uri, String JavaDoc disposition) {
78         this(uri, disposition, -1, null);
79     }
80
81     /**
82      * Create a record from the given URI, disposition, HTTP status code,
83      * and redirect URI.
84      * @param uri
85      * @param disposition
86      * @param statusCode
87      * @param redirectUri
88      */

89     public SeedRecord(String JavaDoc uri, String JavaDoc disposition, int statusCode,
90             String JavaDoc redirectUri) {
91         super();
92         this.uri = uri;
93         this.statusCode = statusCode;
94         this.disposition = disposition;
95         this.redirectUri = redirectUri;
96     }
97
98     /**
99      * @return Returns the disposition.
100      */

101     public String JavaDoc getDisposition() {
102         return disposition;
103     }
104     /**
105      * @return Returns the redirectUri.
106      */

107     public String JavaDoc getRedirectUri() {
108         return redirectUri;
109     }
110     /**
111      * @return Returns the statusCode.
112      */

113     public int getStatusCode() {
114         return statusCode;
115     }
116     /**
117      * @return Returns the uri.
118      */

119     public String JavaDoc getUri() {
120         return uri;
121     }
122 }
Popular Tags