java.lang.Object
java.net.URLConnection
org.bzdev.net.EncapURLConnection
Base class for encapsulating URL connections.
This class stores a URL connection and delegates all the
standard methods for a URL connection to the stored URL
connection.
Subclasses will typically override a few methods, perhaps wrapping them in a doPrivileged block or merely tracing some methods by printing their arguments on an output stream for debugging purposes.
-
Field Summary
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRequestProperty
(String key, String value) void
connect()
boolean
int
getContent
(Class[] classes) int
long
boolean
boolean
boolean
Get the encapsulated URL Connectionlong
getHeaderField
(int n) getHeaderField
(String name) long
getHeaderFieldDate
(String name, long Default) int
getHeaderFieldInt
(String name, int Default) getHeaderFieldKey
(int n) long
getHeaderFieldLong
(String name, long Default) long
long
int
getRequestProperty
(String key) getURL()
boolean
void
setAllowUserInteraction
(boolean allowuserinteraction) void
setConnectTimeout
(int timeout) void
setDefaultUseCaches
(boolean defaultusecaches) void
setDoInput
(boolean doinput) void
setDoOutput
(boolean dooutput) void
setIfModifiedSince
(long ifmodifiedsince) void
setReadTimeout
(int timeout) void
setRequestProperty
(String key, String value) void
setUseCaches
(boolean usecaches) toString()
Methods inherited from class java.net.URLConnection
getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getFileNameMap, guessContentTypeFromName, guessContentTypeFromStream, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setFileNameMap
-
Constructor Details
-
EncapURLConnection
Constructor.- Parameters:
urlc
- the URL connection to encapsulate
-
-
Method Details
-
getEncapsulatedURLConnection
Get the encapsulated URL Connection- Returns:
- the URLConnection passed to the constructor.
-
connect
- Specified by:
connect
in classURLConnection
- Throws:
IOException
-
setConnectTimeout
public void setConnectTimeout(int timeout) - Overrides:
setConnectTimeout
in classURLConnection
-
getConnectTimeout
public int getConnectTimeout()- Overrides:
getConnectTimeout
in classURLConnection
-
setReadTimeout
public void setReadTimeout(int timeout) - Overrides:
setReadTimeout
in classURLConnection
-
getReadTimeout
public int getReadTimeout()- Overrides:
getReadTimeout
in classURLConnection
-
getURL
- Overrides:
getURL
in classURLConnection
-
getContentLength
public int getContentLength()- Overrides:
getContentLength
in classURLConnection
-
getContentLengthLong
public long getContentLengthLong()- Overrides:
getContentLengthLong
in classURLConnection
-
getContentType
- Overrides:
getContentType
in classURLConnection
-
getContentEncoding
- Overrides:
getContentEncoding
in classURLConnection
-
getExpiration
public long getExpiration()- Overrides:
getExpiration
in classURLConnection
-
getLastModified
public long getLastModified()- Overrides:
getLastModified
in classURLConnection
-
getHeaderField
- Overrides:
getHeaderField
in classURLConnection
-
getHeaderFields
- Overrides:
getHeaderFields
in classURLConnection
-
getHeaderFieldInt
- Overrides:
getHeaderFieldInt
in classURLConnection
-
getHeaderFieldLong
- Overrides:
getHeaderFieldLong
in classURLConnection
-
getHeaderFieldDate
- Overrides:
getHeaderFieldDate
in classURLConnection
-
getHeaderFieldKey
- Overrides:
getHeaderFieldKey
in classURLConnection
-
getHeaderField
- Overrides:
getHeaderField
in classURLConnection
-
getContent
- Overrides:
getContent
in classURLConnection
- Throws:
IOException
-
getContent
- Overrides:
getContent
in classURLConnection
- Throws:
IOException
-
getPermission
- Overrides:
getPermission
in classURLConnection
- Throws:
IOException
-
getInputStream
- Overrides:
getInputStream
in classURLConnection
- Throws:
IOException
-
getOutputStream
- Overrides:
getOutputStream
in classURLConnection
- Throws:
IOException
-
toString
- Overrides:
toString
in classURLConnection
-
setDoInput
public void setDoInput(boolean doinput) - Overrides:
setDoInput
in classURLConnection
-
getDoInput
public boolean getDoInput()- Overrides:
getDoInput
in classURLConnection
-
setDoOutput
public void setDoOutput(boolean dooutput) - Overrides:
setDoOutput
in classURLConnection
-
getDoOutput
public boolean getDoOutput()- Overrides:
getDoOutput
in classURLConnection
-
setAllowUserInteraction
public void setAllowUserInteraction(boolean allowuserinteraction) - Overrides:
setAllowUserInteraction
in classURLConnection
-
getAllowUserInteraction
public boolean getAllowUserInteraction()- Overrides:
getAllowUserInteraction
in classURLConnection
-
setUseCaches
public void setUseCaches(boolean usecaches) - Overrides:
setUseCaches
in classURLConnection
-
getUseCaches
public boolean getUseCaches()- Overrides:
getUseCaches
in classURLConnection
-
setIfModifiedSince
public void setIfModifiedSince(long ifmodifiedsince) - Overrides:
setIfModifiedSince
in classURLConnection
-
getIfModifiedSince
public long getIfModifiedSince()- Overrides:
getIfModifiedSince
in classURLConnection
-
getDefaultUseCaches
public boolean getDefaultUseCaches()- Overrides:
getDefaultUseCaches
in classURLConnection
-
setDefaultUseCaches
public void setDefaultUseCaches(boolean defaultusecaches) - Overrides:
setDefaultUseCaches
in classURLConnection
-
setRequestProperty
- Overrides:
setRequestProperty
in classURLConnection
-
addRequestProperty
- Overrides:
addRequestProperty
in classURLConnection
-
getRequestProperty
- Overrides:
getRequestProperty
in classURLConnection
-
getRequestProperties
- Overrides:
getRequestProperties
in classURLConnection
-