1 22 package org.jboss.net.protocol; 23 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.io.OutputStream ; 27 28 import java.net.URLConnection ; 29 import java.net.URL ; 30 import java.net.MalformedURLException ; 31 32 import java.security.Permission ; 33 34 42 public class DelegatingURLConnection 43 extends URLConnection 44 { 45 protected URL delegateUrl; 46 protected URLConnection delegateConnection; 47 48 public DelegatingURLConnection(final URL url) 49 throws MalformedURLException , IOException 50 { 51 super(url); 52 53 delegateUrl = makeDelegateUrl(url); 54 delegateConnection = makeDelegateUrlConnection(delegateUrl); 55 } 56 57 protected URL makeDelegateUrl(final URL url) 58 throws MalformedURLException , IOException 59 { 60 return url; 61 } 62 63 protected URLConnection makeDelegateUrlConnection(final URL url) 64 throws IOException 65 { 66 return url.openConnection(); 67 } 68 69 public void connect() throws IOException 70 { 71 delegateConnection.connect(); 72 } 73 74 public URL getURL() { 75 return delegateConnection.getURL(); 76 } 77 78 public int getContentLength() { 79 return delegateConnection.getContentLength(); 80 } 81 82 public String getContentType() { 83 return delegateConnection.getContentType(); 84 } 85 86 public String getContentEncoding() { 87 return delegateConnection.getContentEncoding(); 88 } 89 90 public long getExpiration() { 91 return delegateConnection.getExpiration(); 92 } 93 94 public long getDate() { 95 return delegateConnection.getDate(); 96 } 97 98 public long getLastModified() { 99 return delegateConnection.getLastModified(); 100 } 101 102 public String getHeaderField(String name) { 103 return delegateConnection.getHeaderField(name); 104 } 105 106 111 112 public int getHeaderFieldInt(String name, int _default) { 113 return delegateConnection.getHeaderFieldInt(name, _default); 114 } 115 116 public long getHeaderFieldDate(String name, long _default) { 117 return delegateConnection.getHeaderFieldDate(name, _default); 118 } 119 120 public String getHeaderFieldKey(int n) { 121 return delegateConnection.getHeaderFieldKey(n); 122 } 123 124 public String getHeaderField(int n) { 125 return delegateConnection.getHeaderField(n); 126 } 127 128 public Object getContent() throws IOException { 129 return delegateConnection.getContent(); 130 } 131 132 public Object getContent(Class [] classes) throws IOException { 133 return delegateConnection.getContent(classes); 134 } 135 136 public Permission getPermission() throws IOException { 137 return delegateConnection.getPermission(); 138 } 139 140 public InputStream getInputStream() throws IOException { 141 return delegateConnection.getInputStream(); 142 } 143 144 public OutputStream getOutputStream() throws IOException { 145 return delegateConnection.getOutputStream(); 146 } 147 148 public String toString() { 149 return super.toString() + "{ " + delegateConnection + " }"; 150 } 151 152 public void setDoInput(boolean doinput) { 153 delegateConnection.setDoInput(doinput); 154 } 155 156 public boolean getDoInput() { 157 return delegateConnection.getDoInput(); 158 } 159 160 public void setDoOutput(boolean dooutput) { 161 delegateConnection.setDoOutput(dooutput); 162 } 163 164 public boolean getDoOutput() { 165 return delegateConnection.getDoOutput(); 166 } 167 168 public void setAllowUserInteraction(boolean allowuserinteraction) { 169 delegateConnection.setAllowUserInteraction(allowuserinteraction); 170 } 171 172 public boolean getAllowUserInteraction() { 173 return delegateConnection.getAllowUserInteraction(); 174 } 175 176 public void setUseCaches(boolean usecaches) { 177 delegateConnection.setUseCaches(usecaches); 178 } 179 180 public boolean getUseCaches() { 181 return delegateConnection.getUseCaches(); 182 } 183 184 public void setIfModifiedSince(long ifmodifiedsince) { 185 delegateConnection.setIfModifiedSince(ifmodifiedsince); 186 } 187 188 public long getIfModifiedSince() { 189 return delegateConnection.getIfModifiedSince(); 190 } 191 192 public boolean getDefaultUseCaches() { 193 return delegateConnection.getDefaultUseCaches(); 194 } 195 196 public void setDefaultUseCaches(boolean defaultusecaches) { 197 delegateConnection.setDefaultUseCaches(defaultusecaches); 198 } 199 200 public void setRequestProperty(String key, String value) { 201 delegateConnection.setRequestProperty(key, value); 202 } 203 204 209 210 public String getRequestProperty(String key) { 211 return delegateConnection.getRequestProperty(key); 212 } 213 214 219 } 220 | Popular Tags |