Class URLRetriever

    • Field Detail

      • EXTRACT_ZIP_ENTRY

        public static final java.lang.String EXTRACT_ZIP_ENTRY
        Applications never need to use this constant. It provides compatibility with very old WorldWind tile servers that deliver zipped content without identifying the content type as other than application/zip. In these cases, the object requesting the content must know the content type to expect, and also requires that the zip file be opened and only its first entry returned.
        See Also:
        Constant Field Values
      • state

        protected volatile java.lang.String state
      • contentLength

        protected volatile int contentLength
      • contentLengthRead

        protected java.util.concurrent.atomic.AtomicInteger contentLengthRead
      • contentType

        protected volatile java.lang.String contentType
      • expiration

        protected java.util.concurrent.atomic.AtomicLong expiration
      • byteBuffer

        protected volatile java.nio.ByteBuffer byteBuffer
      • connection

        protected volatile java.net.URLConnection connection
      • url

        protected final java.net.URL url
      • connectTimeout

        protected int connectTimeout
      • readTimeout

        protected int readTimeout
      • staleRequestLimit

        protected int staleRequestLimit
      • submitTime

        protected long submitTime
      • beginTime

        protected long beginTime
      • endTime

        protected long endTime
    • Constructor Detail

      • URLRetriever

        public URLRetriever​(java.net.URL url,
                            RetrievalPostProcessor postProcessor)
        Parameters:
        url - the URL of the resource to retrieve.
        postProcessor - the retrieval post-processor to invoke when the resource is retrieved. May be null.
        Throws:
        java.lang.IllegalArgumentException - if url.
    • Method Detail

      • createRetriever

        public static URLRetriever createRetriever​(java.net.URL url,
                                                   RetrievalPostProcessor postProcessor)
        Create the appropriate retriever for a URL's protocol.
        Parameters:
        url - the url that will be the source of the retrieval.
        postProcessor - the retriever's post-processor.
        Returns:
        a retriever for the protocol specified in the url, or null if no retriever exists for the protocol.
        Throws:
        java.lang.IllegalArgumentException - if the url is null.
      • getUrl

        public final java.net.URL getUrl()
      • setContentLengthRead

        protected void setContentLengthRead​(int length)
      • getContentType

        public final java.lang.String getContentType()
        Specified by:
        getContentType in interface Retriever
      • getExpirationTime

        public long getExpirationTime()
        Indicates the expiration time of the resource retrieved by this Retriever. Expiration time is determined by either the Expires header, or the max-age directive of the Cache-Control header. Cache-Control has priority if both headers are specified (see section 14.9.3 of the HTTP Specification).
        Specified by:
        getExpirationTime in interface Retriever
        Returns:
        The expiration time of the resource, in milliseconds since the Epoch (January 1, 1970, 00:00:00 GMT). Zero indicates that there is no expiration time.
      • getBuffer

        public final java.nio.ByteBuffer getBuffer()
        Specified by:
        getBuffer in interface Retriever
      • getName

        public final java.lang.String getName()
        Specified by:
        getName in interface Retriever
      • getURL

        public final java.net.URL getURL()
      • getState

        public final java.lang.String getState()
        Specified by:
        getState in interface Retriever
      • getConnection

        protected final java.net.URLConnection getConnection()
      • setReadTimeout

        public void setReadTimeout​(int readTimeout)
        Specified by:
        setReadTimeout in interface Retriever
      • setConnectTimeout

        public final void setConnectTimeout​(int connectTimeout)
        Specified by:
        setConnectTimeout in interface Retriever
      • setSubmitTime

        public void setSubmitTime​(long submitTime)
        Specified by:
        setSubmitTime in interface Retriever
      • setBeginTime

        public void setBeginTime​(long beginTime)
        Specified by:
        setBeginTime in interface Retriever
      • setEndTime

        public void setEndTime​(long endTime)
        Specified by:
        setEndTime in interface Retriever
      • call

        public final Retriever call()
                             throws java.lang.Exception
        Specified by:
        call in interface java.util.concurrent.Callable<Retriever>
        Throws:
        java.lang.Exception
      • setState

        protected void setState​(java.lang.String state)
      • interrupted

        protected boolean interrupted()
      • openConnection

        protected java.net.URLConnection openConnection()
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • configureSSLContext

        protected void configureSSLContext​(javax.net.ssl.HttpsURLConnection connection)
      • end

        protected void end()
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • read

        protected java.nio.ByteBuffer read()
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • doRead

        protected java.nio.ByteBuffer doRead​(java.net.URLConnection connection)
                                      throws java.lang.Exception
        Parameters:
        connection - the connection to read from.
        Returns:
        a buffer containing the content read from the connection
        Throws:
        java.lang.Exception - if connection is null or an exception occurs during reading.
        java.lang.IllegalArgumentException - if connection is null
      • readNonSpecificStream

        protected java.nio.ByteBuffer readNonSpecificStream​(java.io.InputStream inputStream,
                                                            java.net.URLConnection connection)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readNonSpecificStreamUnknownLength

        protected java.nio.ByteBuffer readNonSpecificStreamUnknownLength​(java.io.InputStream inputStream)
                                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readZipStream

        protected java.nio.ByteBuffer readZipStream​(java.io.InputStream inputStream,
                                                    java.net.URL url)
                                             throws java.io.IOException
        Parameters:
        inputStream - a stream to the zip connection.
        url - the URL of the zip resource.
        Returns:
        a buffer containing the content read from the zip stream.
        Throws:
        java.io.IOException - if the stream does not refer to a zip resource or an exception occurs during reading.
        java.lang.IllegalArgumentException - if inputStream is null
      • getExpiration

        protected long getExpiration​(java.net.URLConnection connection)
        Indicates the expiration time specified by either the Expires header or the max-age directive of the Cache-Control header. If both are present, then Cache-Control is given priority (See section 14.9.3 of the HTTP Specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).

        If both the Expires and Date headers are present then the expiration time is calculated as current time + (expires - date). This helps guard against clock skew between the client and server.

        Parameters:
        connection - Connection for which to get expiration time.
        Returns:
        The expiration time, in milliseconds since the Epoch, specified by the HTTP headers, or zero if there is no expiration time.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object