Source Code Cross Referenced for HttpURLConnection.java in  » Mail-Clients » columba-1.4 » org » columba » core » url » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.core.url.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:
017:        package org.columba.core.url.http;
018:
019:        import java.io.IOException;
020:        import java.io.InputStream;
021:        import java.io.OutputStream;
022:        import java.net.ProtocolException;
023:        import java.net.URL;
024:        import java.security.Permission;
025:        import java.util.Map;
026:        import java.util.logging.Logger;
027:
028:        import org.columba.core.connectionstate.ConnectionStateImpl;
029:
030:        /**
031:         * This class acts as a proxy between clients using HTTP URLs and the underlying
032:         * URLConnection implementation. Depending on the system's connection state
033:         * it throws IOExceptions indicating that there is no internet connection
034:         * available.
035:         */
036:        public class HttpURLConnection extends java.net.HttpURLConnection {
037:            private static final Logger LOG = Logger
038:                    .getLogger("org.columba.core.url.http");
039:
040:            protected java.net.HttpURLConnection connection;
041:
042:            public HttpURLConnection(URL u,
043:                    java.net.HttpURLConnection connection) {
044:                super (u);
045:                this .connection = connection;
046:                connection.setUseCaches(false);
047:                connection.setDefaultUseCaches(false);
048:            }
049:
050:            /**
051:             * Checks whether a connection is available and throws a IOConnection if not.
052:             */
053:            protected void ensureConnectionAllowed() throws IOException {
054:                if (!ConnectionStateImpl.getInstance().isOnline()) {
055:                    LOG.fine("Blocking HTTP connection to "
056:                            + getURL().toString());
057:                    throw new IOException("Error while connecting.");
058:                }
059:            }
060:
061:            public OutputStream getOutputStream() throws IOException {
062:                ensureConnectionAllowed();
063:                return connection.getOutputStream();
064:            }
065:
066:            public void setDefaultUseCaches(boolean param) {
067:            }
068:
069:            public long getIfModifiedSince() {
070:                return connection.getIfModifiedSince();
071:            }
072:
073:            public String getResponseMessage() throws IOException {
074:                if (!ConnectionStateImpl.getInstance().isOnline()) {
075:                    return "Not Found";
076:                } else {
077:                    return connection.getResponseMessage();
078:                }
079:            }
080:
081:            public Permission getPermission() throws IOException {
082:                return connection.getPermission();
083:            }
084:
085:            public void setUseCaches(boolean param) {
086:            }
087:
088:            public void addRequestProperty(String str, String str1) {
089:                connection.addRequestProperty(str, str1);
090:            }
091:
092:            public boolean getInstanceFollowRedirects() {
093:                return connection.getInstanceFollowRedirects();
094:            }
095:
096:            public Map getRequestProperties() {
097:                return connection.getRequestProperties();
098:            }
099:
100:            public void setRequestMethod(String str) throws ProtocolException {
101:                super .setRequestMethod(str);
102:            }
103:
104:            public boolean getDefaultUseCaches() {
105:                return connection.getDefaultUseCaches();
106:            }
107:
108:            public String getRequestMethod() {
109:                return connection.getRequestMethod();
110:            }
111:
112:            public boolean getDoOutput() {
113:                return connection.getDoOutput();
114:            }
115:
116:            public long getDate() {
117:                return connection.getDate();
118:            }
119:
120:            public int getResponseCode() throws IOException {
121:                if (!ConnectionStateImpl.getInstance().isOnline()) {
122:                    return HTTP_NOT_FOUND;
123:                } else {
124:                    return connection.getResponseCode();
125:                }
126:            }
127:
128:            public long getHeaderFieldDate(String str, long param) {
129:                return connection.getHeaderFieldDate(str, param);
130:            }
131:
132:            public boolean usingProxy() {
133:                return connection.usingProxy();
134:            }
135:
136:            public void setRequestProperty(String str, String str1) {
137:                connection.setRequestProperty(str, str1);
138:            }
139:
140:            public String getHeaderField(int param) {
141:                return connection.getHeaderField(param);
142:            }
143:
144:            public void setAllowUserInteraction(boolean param) {
145:                super .setAllowUserInteraction(param);
146:            }
147:
148:            public String getHeaderField(String str) {
149:                return connection.getHeaderField(str);
150:            }
151:
152:            public InputStream getErrorStream() {
153:                return connection.getErrorStream();
154:            }
155:
156:            public Object getContent(Class[] clazz) throws IOException {
157:                ensureConnectionAllowed();
158:                return connection.getContent(clazz);
159:            }
160:
161:            public void disconnect() {
162:                connection.disconnect();
163:            }
164:
165:            public String getHeaderFieldKey(int param) {
166:                return connection.getHeaderFieldKey(param);
167:            }
168:
169:            public long getExpiration() {
170:                return connection.getExpiration();
171:            }
172:
173:            public void setDoInput(boolean param) {
174:                connection.setDoInput(param);
175:            }
176:
177:            public Object getContent() throws IOException {
178:                ensureConnectionAllowed();
179:                return connection.getContent();
180:            }
181:
182:            public boolean getUseCaches() {
183:                return connection.getUseCaches();
184:            }
185:
186:            public long getLastModified() {
187:                return connection.getLastModified();
188:            }
189:
190:            public boolean getDoInput() {
191:                return connection.getDoInput();
192:            }
193:
194:            public String getContentType() {
195:                return connection.getContentType();
196:            }
197:
198:            public Map getHeaderFields() {
199:                return connection.getHeaderFields();
200:            }
201:
202:            public void setDoOutput(boolean param) {
203:                connection.setDoOutput(param);
204:            }
205:
206:            public InputStream getInputStream() throws IOException {
207:                ensureConnectionAllowed();
208:                return connection.getInputStream();
209:            }
210:
211:            public String getRequestProperty(String str) {
212:                return connection.getRequestProperty(str);
213:            }
214:
215:            public int getHeaderFieldInt(String str, int param) {
216:                return connection.getHeaderFieldInt(str, param);
217:            }
218:
219:            public void setInstanceFollowRedirects(boolean param) {
220:                connection.setInstanceFollowRedirects(param);
221:            }
222:
223:            public void setIfModifiedSince(long param) {
224:                connection.setIfModifiedSince(param);
225:            }
226:
227:            public String getContentEncoding() {
228:                return connection.getContentEncoding();
229:            }
230:
231:            public void connect() throws IOException {
232:                ensureConnectionAllowed();
233:                connection.connect();
234:            }
235:
236:            public int getContentLength() {
237:                return connection.getContentLength();
238:            }
239:
240:            public boolean getAllowUserInteraction() {
241:                return connection.getAllowUserInteraction();
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.