Class DataURLConnection


  • public class DataURLConnection
    extends java.net.URLConnection
    A connection to a data: URL as specified in RFC 2397.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] data  
      private java.io.InputStream inputStream  
      private MediaType mediaType  
      • Fields inherited from class java.net.URLConnection

        allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
    • 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
      void connect()
      java.lang.String getContentEncoding()
      Returns the content encoding of the data URL.
      int getContentLength()
      Returns the length of the decoded data part of the data URL.
      long getContentLengthLong()
      Returns the length of the decoded data part of the data URL.
      java.lang.String getContentType()
      Returns the media type of the data URL.
      java.io.InputStream getInputStream()
      • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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:
        connect in class java.net.URLConnection
      • getContentLength

        public int getContentLength()
        Returns the length of the decoded data part of the data URL.
        Overrides:
        getContentLength in class java.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:
        getContentLengthLong in class java.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 be text/plain;charset=US-ASCII, as specified in RFC 2397.
        Overrides:
        getContentType in class java.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 be US-ASCII.

        Overrides:
        getContentEncoding in class java.net.URLConnection
        Returns:
        The content encoding of the data URL.
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Overrides:
        getInputStream in class java.net.URLConnection
        Throws:
        java.io.IOException