KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > HttpRequest


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on Nov 13, 2005
23  */

24 package org.lobobrowser.html;
25
26 import java.awt.Image JavaDoc;
27 import java.net.URL JavaDoc;
28
29 import org.w3c.dom.Document JavaDoc;
30
31 /**
32  * The <code>HttpRequest</code> interface should
33  * be implemented to provide web request capabilities.
34  */

35 public interface HttpRequest {
36     /**
37      * The uninitialized request state.
38      */

39     public static final int STATE_UNINITIALIZED = 0;
40     
41     /**
42      * The loading request state.
43      */

44     public static final int STATE_LOADING = 1;
45     
46     /**
47      * The loaded request state.
48      */

49     public static final int STATE_LOADED = 2;
50     
51     /**
52      * The interactive request state.
53      */

54     public static final int STATE_INTERACTIVE = 3;
55     
56     /**
57      * The complete request state.
58      */

59     public static final int STATE_COMPLETE = 4;
60
61     /**
62      * Gets the state of the request, a value
63      * between 0 and 4.
64      * @return A value corresponding to one of the STATE* constants in this class.
65      */

66     public int getReadyState();
67     
68     /**
69      * Gets the request response as text.
70      */

71     public String JavaDoc getResponseText();
72     
73     /**
74      * Gets the request response as an XML DOM.
75      */

76     public Document JavaDoc getResponseXML();
77     
78     /**
79      * Gets the request response as an AWT image.
80      */

81     public Image JavaDoc getResponseImage();
82     
83     /**
84      * Gets the request response bytes.
85      */

86     public byte[] getResponseBytes();
87     
88     /**
89      * Gets the status of the response. Note that this
90      * can be 0 for file requests in addition to 200
91      * for successful HTTP requests.
92      */

93     public int getStatus();
94     
95     /**
96      * Gets the status text of the request, e.g. "OK" for 200.
97      */

98     public String JavaDoc getStatusText();
99     
100     /**
101      * Aborts an ongoing request.
102      */

103     public void abort();
104     
105     /**
106      * Gets a string with all the response headers.
107      */

108     public String JavaDoc getAllResponseHeaders();
109     
110     /**
111      * Gets a response header value.
112      * @param headerName The name of the header.
113      */

114     public String JavaDoc getResponseHeader(String JavaDoc headerName);
115     
116     /**
117      * Starts an asynchronous request.
118      * @param method The request method.
119      * @param url The destination URL.
120      */

121     public void open(String JavaDoc method, String JavaDoc url);
122     
123     /**
124      * Opens an asynchronous request.
125      * @param method The request method.
126      * @param url The destination URL.
127      */

128     public void open(String JavaDoc method, URL JavaDoc url);
129     
130     /**
131      * Opens an request.
132      * @param method The request method.
133      * @param url The destination URL.
134      * @param asyncFlag Whether the request is asynchronous.
135      */

136     public void open(String JavaDoc method, URL JavaDoc url, boolean asyncFlag);
137
138     /**
139      * Opens a request.
140      * @param method The request method.
141      * @param url The destination URL.
142      * @param asyncFlag Whether the request should be asynchronous.
143      */

144     public void open(String JavaDoc method, String JavaDoc url, boolean asyncFlag);
145     
146     /**
147      * Opens a request.
148      * @param method The request method.
149      * @param url The destination URL.
150      * @param asyncFlag Whether the request should be asynchronous.
151      * @param userName The HTTP authentication user name.
152      */

153     public void open(String JavaDoc method, String JavaDoc url, boolean asyncFlag, String JavaDoc userName);
154
155     /**
156      * Opens a request.
157      * @param method The request method.
158      * @param url The destination URL.
159      * @param asyncFlag Whether the request should be asynchronous.
160      * @param userName The HTTP authentication user name.
161      * @param password The HTTP authentication password.
162      */

163     public void open(String JavaDoc method, String JavaDoc url, boolean asyncFlag, String JavaDoc userName, String JavaDoc password);
164
165     /**
166      * Adds a listener of ReadyState changes. The listener should be invoked
167      * even in the case of errors.
168      * @param listener An instanceof of {@link org.lobobrowser.html.ReadyStateChangeListener}
169      */

170     public void addReadyStateChangeListener(ReadyStateChangeListener listener);
171 }
172
Popular Tags