Package io.microsphere.net
Class DelegatingURLConnection
- java.lang.Object
-
- java.net.URLConnection
-
- io.microsphere.net.DelegatingURLConnection
-
public class DelegatingURLConnection extends java.net.URLConnectionA delegating implementation ofURLConnectionthat forwards all method calls to a provided delegate instance. This class can be used as a base class for creating specialized URLConnection wrappers that need to intercept or modify behavior of the underlying connection without changing its core functionality.Example Usage
URL url = new URL("http://example.com"); URLConnection connection = url.openConnection(); DelegatingURLConnection wrapper = new DelegatingURLConnection(connection) {};- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description DelegatingURLConnection(java.net.URLConnection delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRequestProperty(java.lang.String key, java.lang.String value)voidconnect()booleangetAllowUserInteraction()intgetConnectTimeout()java.lang.ObjectgetContent()java.lang.ObjectgetContent(java.lang.Class[] classes)java.lang.StringgetContentEncoding()intgetContentLength()longgetContentLengthLong()java.lang.StringgetContentType()longgetDate()booleangetDefaultUseCaches()booleangetDoInput()booleangetDoOutput()longgetExpiration()java.lang.StringgetHeaderField(int n)java.lang.StringgetHeaderField(java.lang.String name)longgetHeaderFieldDate(java.lang.String name, long Default)intgetHeaderFieldInt(java.lang.String name, int Default)java.lang.StringgetHeaderFieldKey(int n)longgetHeaderFieldLong(java.lang.String name, long Default)java.util.Map<java.lang.String,java.util.List<java.lang.String>>getHeaderFields()longgetIfModifiedSince()java.io.InputStreamgetInputStream()longgetLastModified()java.io.OutputStreamgetOutputStream()java.security.PermissiongetPermission()intgetReadTimeout()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getRequestProperties()java.lang.StringgetRequestProperty(java.lang.String key)java.net.URLgetURL()booleangetUseCaches()voidsetAllowUserInteraction(boolean allowuserinteraction)voidsetConnectTimeout(int timeout)voidsetDefaultUseCaches(boolean defaultusecaches)voidsetDoInput(boolean doinput)voidsetDoOutput(boolean dooutput)voidsetIfModifiedSince(long ifmodifiedsince)voidsetReadTimeout(int timeout)voidsetRequestProperty(java.lang.String key, java.lang.String value)voidsetUseCaches(boolean usecaches)java.lang.StringtoString()
-
-
-
Method Detail
-
connect
public void connect() throws java.io.IOException- Specified by:
connectin classjava.net.URLConnection- Throws:
java.io.IOException
-
setConnectTimeout
public void setConnectTimeout(int timeout)
- Overrides:
setConnectTimeoutin classjava.net.URLConnection
-
getConnectTimeout
public int getConnectTimeout()
- Overrides:
getConnectTimeoutin classjava.net.URLConnection
-
setReadTimeout
public void setReadTimeout(int timeout)
- Overrides:
setReadTimeoutin classjava.net.URLConnection
-
getReadTimeout
public int getReadTimeout()
- Overrides:
getReadTimeoutin classjava.net.URLConnection
-
getURL
public java.net.URL getURL()
- Overrides:
getURLin classjava.net.URLConnection
-
getContentLength
public int getContentLength()
- Overrides:
getContentLengthin classjava.net.URLConnection
-
getContentLengthLong
public long getContentLengthLong()
- Overrides:
getContentLengthLongin classjava.net.URLConnection
-
getContentType
public java.lang.String getContentType()
- Overrides:
getContentTypein classjava.net.URLConnection
-
getContentEncoding
public java.lang.String getContentEncoding()
- Overrides:
getContentEncodingin classjava.net.URLConnection
-
getExpiration
public long getExpiration()
- Overrides:
getExpirationin classjava.net.URLConnection
-
getDate
public long getDate()
- Overrides:
getDatein classjava.net.URLConnection
-
getLastModified
public long getLastModified()
- Overrides:
getLastModifiedin classjava.net.URLConnection
-
getHeaderField
public java.lang.String getHeaderField(java.lang.String name)
- Overrides:
getHeaderFieldin classjava.net.URLConnection
-
getHeaderFields
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaderFields()
- Overrides:
getHeaderFieldsin classjava.net.URLConnection
-
getHeaderFieldInt
public int getHeaderFieldInt(java.lang.String name, int Default)- Overrides:
getHeaderFieldIntin classjava.net.URLConnection
-
getHeaderFieldLong
public long getHeaderFieldLong(java.lang.String name, long Default)- Overrides:
getHeaderFieldLongin classjava.net.URLConnection
-
getHeaderFieldDate
public long getHeaderFieldDate(java.lang.String name, long Default)- Overrides:
getHeaderFieldDatein classjava.net.URLConnection
-
getHeaderFieldKey
public java.lang.String getHeaderFieldKey(int n)
- Overrides:
getHeaderFieldKeyin classjava.net.URLConnection
-
getHeaderField
public java.lang.String getHeaderField(int n)
- Overrides:
getHeaderFieldin classjava.net.URLConnection
-
getContent
public java.lang.Object getContent() throws java.io.IOException- Overrides:
getContentin classjava.net.URLConnection- Throws:
java.io.IOException
-
getContent
public java.lang.Object getContent(java.lang.Class[] classes) throws java.io.IOException- Overrides:
getContentin classjava.net.URLConnection- Throws:
java.io.IOException
-
getPermission
public java.security.Permission getPermission() throws java.io.IOException- Overrides:
getPermissionin classjava.net.URLConnection- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Overrides:
getInputStreamin classjava.net.URLConnection- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException- Overrides:
getOutputStreamin classjava.net.URLConnection- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.net.URLConnection
-
setDoInput
public void setDoInput(boolean doinput)
- Overrides:
setDoInputin classjava.net.URLConnection
-
getDoInput
public boolean getDoInput()
- Overrides:
getDoInputin classjava.net.URLConnection
-
setDoOutput
public void setDoOutput(boolean dooutput)
- Overrides:
setDoOutputin classjava.net.URLConnection
-
getDoOutput
public boolean getDoOutput()
- Overrides:
getDoOutputin classjava.net.URLConnection
-
setAllowUserInteraction
public void setAllowUserInteraction(boolean allowuserinteraction)
- Overrides:
setAllowUserInteractionin classjava.net.URLConnection
-
getAllowUserInteraction
public boolean getAllowUserInteraction()
- Overrides:
getAllowUserInteractionin classjava.net.URLConnection
-
setUseCaches
public void setUseCaches(boolean usecaches)
- Overrides:
setUseCachesin classjava.net.URLConnection
-
getUseCaches
public boolean getUseCaches()
- Overrides:
getUseCachesin classjava.net.URLConnection
-
setIfModifiedSince
public void setIfModifiedSince(long ifmodifiedsince)
- Overrides:
setIfModifiedSincein classjava.net.URLConnection
-
getIfModifiedSince
public long getIfModifiedSince()
- Overrides:
getIfModifiedSincein classjava.net.URLConnection
-
getDefaultUseCaches
public boolean getDefaultUseCaches()
- Overrides:
getDefaultUseCachesin classjava.net.URLConnection
-
setDefaultUseCaches
public void setDefaultUseCaches(boolean defaultusecaches)
- Overrides:
setDefaultUseCachesin classjava.net.URLConnection
-
setRequestProperty
public void setRequestProperty(java.lang.String key, java.lang.String value)- Overrides:
setRequestPropertyin classjava.net.URLConnection
-
addRequestProperty
public void addRequestProperty(java.lang.String key, java.lang.String value)- Overrides:
addRequestPropertyin classjava.net.URLConnection
-
getRequestProperty
public java.lang.String getRequestProperty(java.lang.String key)
- Overrides:
getRequestPropertyin classjava.net.URLConnection
-
getRequestProperties
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestProperties()
- Overrides:
getRequestPropertiesin classjava.net.URLConnection
-
-