View Javadoc

1   
2   /*
3    * SmartCrawler
4    *
5    * $Id: HttpCall.java,v 1.4 2005/07/24 20:01:48 vincool Exp $
6    * Copyright 2005 Davide Pozza
7    *
8    * This program is free software; you can redistribute it
9    * and/or modify it under the terms of the GNU General Public
10   * License as published by the Free Software Foundation;
11   * either version 2 of the License, or (at your option) any
12   * later version.
13   *
14   * This program is distributed in the hope that it will be
15   * useful, but WITHOUT ANY WARRANTY; without even the implied
16   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17   * PURPOSE. See the GNU General Public License for more
18   * details.
19   *
20   * You should have received a copy of the GNU General Public
21   * License along with this program; if not, write to the Free
22   * Software Foundation, Inc., 59 Temple Place, Suite 330,
23   * Boston, MA 02111-1307 USA
24   *
25   */
26  
27  package org.smartcrawler.retriever;
28  import java.util.Hashtable;
29  import org.smartcrawler.common.Link;
30  
31  
32  /***
33   *
34   *
35   * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
36   * @version <tt>$Revision: 1.4 $</tt>
37   */
38  public class HttpCall implements Call {
39  
40      private Hashtable params = new Hashtable();
41      private Link link;
42      private String userAgent;
43      private int method;
44      private Content content;
45  
46      private static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.5) Gecko/20041110 Firefox/1.0";
47  
48      /***
49       * Creates a new instance of HttpCall
50       * @param link
51       */
52      public HttpCall(Link link) {
53          this.link = link;
54          setUserAgent(DEFAULT_USER_AGENT);
55          setMethod(GET);
56      }
57  
58      /***
59       *
60       * @param link
61       * @param method
62       */
63      public HttpCall(Link link, int method) {
64          this.link = link;
65          setUserAgent(DEFAULT_USER_AGENT);
66          setMethod(method);
67      }
68  
69      /***
70       *
71       * @return
72       */
73      public Link getLink() {
74          return this.link;
75      }
76  
77      /***
78       *
79       * @param key
80       * @param value
81       */
82      public void addParameter(String key, String value) {
83          params.put(key, value);
84      }
85  
86      /***
87       *
88       * @return
89       */
90      public String getUserAgent() {
91          return userAgent;
92      }
93  
94      /***
95       *
96       * @param userAgent
97       */
98      public void setUserAgent(String userAgent) {
99          this.userAgent = userAgent;
100     }
101 
102     /***
103      *
104      * @return
105      */
106     public int getMethod() {
107         return method;
108     }
109 
110     /***
111      *
112      * @param method
113      */
114     public void setMethod(int method) {
115         this.method = method;
116     }
117 
118     /***
119      *
120      * @return
121      */
122     public Content getContent() {
123         return content;
124     }
125 
126     /***
127      *
128      * @param content
129      */
130     public void setContent(Content content) {
131         this.content = content;
132     }
133 
134 
135 }