Class DataURLConnection
- java.lang.Object
-
- java.net.URLConnection
-
- com.github.robtimus.net.protocol.data.DataURLConnection
-
public class DataURLConnection extends java.net.URLConnectionA connection to adata:URL as specified in RFC 2397.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]dataprivate java.io.InputStreaminputStreamprivate MediaTypemediaType
-
Constructor Summary
Constructors Constructor Description DataURLConnection(java.net.URL url, MediaType mediaType, byte[] data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()java.lang.StringgetContentEncoding()Returns the content encoding of the data URL.intgetContentLength()Returns the length of the decoded data part of the data URL.longgetContentLengthLong()Returns the length of the decoded data part of the data URL.java.lang.StringgetContentType()Returns the media type of the data URL.java.io.InputStreamgetInputStream()-
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
-
-
-
Field Detail
-
mediaType
private final MediaType mediaType
-
data
private final byte[] data
-
inputStream
private java.io.InputStream inputStream
-
-
Constructor Detail
-
DataURLConnection
DataURLConnection(java.net.URL url, MediaType mediaType, byte[] data)
-
-
Method Detail
-
connect
public void connect()
- Specified by:
connectin classjava.net.URLConnection
-
getContentLength
public int getContentLength()
Returns the length of the decoded data part of the data URL.- Overrides:
getContentLengthin classjava.net.URLConnection- Returns:
- The length of the decoded data part of the data URL.
-
getContentLengthLong
public long getContentLengthLong()
Returns the length of the decoded data part of the data URL.- Overrides:
getContentLengthLongin classjava.net.URLConnection- Returns:
- The length of the decoded data part of the data URL.
-
getContentType
public java.lang.String getContentType()
Returns the media type of the data URL. If none is specified it will betext/plain;charset=US-ASCII, as specified in RFC 2397.- Overrides:
getContentTypein classjava.net.URLConnection- Returns:
- The media type of the data URL.
-
getContentEncoding
public java.lang.String getContentEncoding()
Returns the content encoding of the data URL. This is taken from the data URL's media type.If no media type is specified, it is assumed to be
text/plain;charset=US-ASCII, as specified in RFC 2397. As a result, the content encoding will then beUS-ASCII.- Overrides:
getContentEncodingin classjava.net.URLConnection- Returns:
- The content encoding of the data URL.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Overrides:
getInputStreamin classjava.net.URLConnection- Throws:
java.io.IOException
-
-