Class JarURLConnectionImpl


  • public class JarURLConnectionImpl
    extends JarURLConnection
    This subclass extends URLConnection.

    This class is responsible for connecting and retrieving resources from a Jar file which can be anywhere that can be referred to by an URL.

    • Method Detail

      • getJarFile

        public JarFile getJarFile()
                           throws IOException
        Returns the Jar file referred by this URLConnection.
        Specified by:
        getJarFile in class JarURLConnection
        Returns:
        the referenced JarFile object.
        Throws:
        IOException - thrown if an IO error occurs while connecting to the resource.
      • getContentType

        public String getContentType()
        Returns the content type of the resource. For jar file itself "x-java/jar" should be returned, for jar entries the content type of the entry should be returned. Returns non-null results ("content/unknown" for unknown types).
        Overrides:
        getContentType in class URLConnection
        Returns:
        the content type
      • getContentLength

        public int getContentLength()
        Returns the content length of the resource. Test cases reveal that if the URL is referring to a Jar file, this method answers a content-length returned by URLConnection. For a jar entry it returns the entry's size if it can be represented as an int. Otherwise, it will return -1.
        Overrides:
        getContentLength in class URLConnection
      • getPermission

        public Permission getPermission()
                                 throws IOException
        Returns the permission, in this case the subclass, FilePermission object which represents the permission necessary for this URLConnection to establish the connection.
        Overrides:
        getPermission in class URLConnection
        Returns:
        the permission required for this URLConnection.
        Throws:
        IOException - thrown when an IO exception occurs while creating the permission.
      • getUseCaches

        public boolean getUseCaches()
        Description copied from class: URLConnection
        Returns the value of the flag which specifies whether this URLConnection allows to use caches.
        Overrides:
        getUseCaches in class URLConnection
        Returns:
        true if using caches is allowed, false otherwise.
      • setUseCaches

        public void setUseCaches​(boolean usecaches)
        Description copied from class: URLConnection
        Sets the flag indicating whether this connection allows to use caches or not. This method can only be called prior to the connection establishment.
        Overrides:
        setUseCaches in class URLConnection
        Parameters:
        usecaches - the value of the flag to be set.
        See Also:
        URLConnection.useCaches
      • setDefaultUseCaches

        public void setDefaultUseCaches​(boolean defaultusecaches)
        Description copied from class: URLConnection
        Sets the default value for the flag indicating whether this connection allows to use caches. Existing URLConnections are unaffected.
        Overrides:
        setDefaultUseCaches in class URLConnection
        Parameters:
        defaultusecaches - the default value of the flag to be used for new connections.
        See Also:
        URLConnection.useCaches