Package gov.nasa.worldwind.retrieve
Class URLRetriever
- java.lang.Object
- 
- gov.nasa.worldwind.avlist.AVListImpl
- 
- gov.nasa.worldwind.WWObjectImpl
- 
- gov.nasa.worldwind.retrieve.URLRetriever
 
 
 
- 
- All Implemented Interfaces:
- AVList,- MessageListener,- Retriever,- WWObject,- java.beans.PropertyChangeListener,- java.util.concurrent.Callable<Retriever>,- java.util.EventListener
 - Direct Known Subclasses:
- HTTPRetriever,- JarRetriever
 
 public abstract class URLRetriever extends WWObjectImpl implements Retriever 
- 
- 
Field SummaryFields Modifier and Type Field Description protected longbeginTimeprotected java.nio.ByteBufferbyteBufferprotected java.net.URLConnectionconnectionprotected intconnectTimeoutprotected intcontentLengthprotected java.util.concurrent.atomic.AtomicIntegercontentLengthReadprotected java.lang.StringcontentTypeprotected longendTimeprotected java.util.concurrent.atomic.AtomicLongexpirationstatic java.lang.StringEXTRACT_ZIP_ENTRYApplications never need to use this constant.protected RetrievalPostProcessorpostProcessorprotected intreadTimeoutprotected intstaleRequestLimitprotected java.lang.Stringstateprotected longsubmitTimeprotected java.net.URLurl- 
Fields inherited from interface gov.nasa.worldwind.retrieve.RetrieverRETRIEVER_STATE_CONNECTING, RETRIEVER_STATE_ERROR, RETRIEVER_STATE_INTERRUPTED, RETRIEVER_STATE_NOT_STARTED, RETRIEVER_STATE_READING, RETRIEVER_STATE_STARTED, RETRIEVER_STATE_SUCCESSFUL
 
- 
 - 
Constructor SummaryConstructors Constructor Description URLRetriever(java.net.URL url, RetrievalPostProcessor postProcessor)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Retrievercall()protected voidconfigureSSLContext(javax.net.ssl.HttpsURLConnection connection)static URLRetrievercreateRetriever(java.net.URL url, RetrievalPostProcessor postProcessor)Create the appropriate retriever for a URL's protocol.protected java.nio.ByteBufferdoRead(java.net.URLConnection connection)protected voidend()booleanequals(java.lang.Object o)longgetBeginTime()java.nio.ByteBuffergetBuffer()protected java.net.URLConnectiongetConnection()intgetConnectTimeout()intgetContentLength()intgetContentLengthRead()java.lang.StringgetContentType()longgetEndTime()protected longgetExpiration(java.net.URLConnection connection)Indicates the expiration time specified by either the Expires header or the max-age directive of the Cache-Control header.longgetExpirationTime()Indicates the expiration time of the resource retrieved by this Retriever.java.lang.StringgetName()RetrievalPostProcessorgetPostProcessor()intgetReadTimeout()intgetStaleRequestLimit()java.lang.StringgetState()longgetSubmitTime()java.net.URLgetUrl()java.net.URLgetURL()inthashCode()protected booleaninterrupted()protected java.net.URLConnectionopenConnection()protected java.nio.ByteBufferread()protected java.nio.ByteBufferreadNonSpecificStream(java.io.InputStream inputStream, java.net.URLConnection connection)protected java.nio.ByteBufferreadNonSpecificStreamUnknownLength(java.io.InputStream inputStream)protected java.nio.ByteBufferreadZipStream(java.io.InputStream inputStream, java.net.URL url)voidsetBeginTime(long beginTime)voidsetConnectTimeout(int connectTimeout)protected voidsetContentLengthRead(int length)voidsetEndTime(long endTime)voidsetReadTimeout(int readTimeout)voidsetStaleRequestLimit(int staleRequestLimit)protected voidsetState(java.lang.String state)voidsetSubmitTime(long submitTime)java.lang.StringtoString()- 
Methods inherited from class gov.nasa.worldwind.WWObjectImplonMessage, propertyChange
 - 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpladdPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 - 
Methods inherited from interface gov.nasa.worldwind.avlist.AVListaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 - 
Methods inherited from interface gov.nasa.worldwind.event.MessageListeneronMessage
 
- 
 
- 
- 
- 
Field Detail- 
EXTRACT_ZIP_ENTRYpublic 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
 
 - 
stateprotected volatile java.lang.String state 
 - 
contentLengthprotected volatile int contentLength 
 - 
contentLengthReadprotected java.util.concurrent.atomic.AtomicInteger contentLengthRead 
 - 
contentTypeprotected volatile java.lang.String contentType 
 - 
expirationprotected java.util.concurrent.atomic.AtomicLong expiration 
 - 
byteBufferprotected volatile java.nio.ByteBuffer byteBuffer 
 - 
connectionprotected volatile java.net.URLConnection connection 
 - 
urlprotected final java.net.URL url 
 - 
postProcessorprotected final RetrievalPostProcessor postProcessor 
 - 
connectTimeoutprotected int connectTimeout 
 - 
readTimeoutprotected int readTimeout 
 - 
staleRequestLimitprotected int staleRequestLimit 
 - 
submitTimeprotected long submitTime 
 - 
beginTimeprotected long beginTime 
 - 
endTimeprotected long endTime 
 
- 
 - 
Constructor Detail- 
URLRetrieverpublic 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- 
createRetrieverpublic 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.
 
 - 
getUrlpublic final java.net.URL getUrl() 
 - 
getContentLengthpublic final int getContentLength() - Specified by:
- getContentLengthin interface- Retriever
 
 - 
setContentLengthReadprotected void setContentLengthRead(int length) 
 - 
getContentLengthReadpublic final int getContentLengthRead() - Specified by:
- getContentLengthReadin interface- Retriever
 
 - 
getContentTypepublic final java.lang.String getContentType() - Specified by:
- getContentTypein interface- Retriever
 
 - 
getExpirationTimepublic 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:
- getExpirationTimein 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.
 
 - 
getBufferpublic final java.nio.ByteBuffer getBuffer() 
 - 
getURLpublic final java.net.URL getURL() 
 - 
getConnectionprotected final java.net.URLConnection getConnection() 
 - 
getPostProcessorpublic final RetrievalPostProcessor getPostProcessor() 
 - 
getConnectTimeoutpublic final int getConnectTimeout() - Specified by:
- getConnectTimeoutin interface- Retriever
 
 - 
getReadTimeoutpublic int getReadTimeout() - Specified by:
- getReadTimeoutin interface- Retriever
 
 - 
setReadTimeoutpublic void setReadTimeout(int readTimeout) - Specified by:
- setReadTimeoutin interface- Retriever
 
 - 
getStaleRequestLimitpublic int getStaleRequestLimit() - Specified by:
- getStaleRequestLimitin interface- Retriever
 
 - 
setStaleRequestLimitpublic void setStaleRequestLimit(int staleRequestLimit) - Specified by:
- setStaleRequestLimitin interface- Retriever
 
 - 
setConnectTimeoutpublic final void setConnectTimeout(int connectTimeout) - Specified by:
- setConnectTimeoutin interface- Retriever
 
 - 
getSubmitTimepublic long getSubmitTime() - Specified by:
- getSubmitTimein interface- Retriever
 
 - 
setSubmitTimepublic void setSubmitTime(long submitTime) - Specified by:
- setSubmitTimein interface- Retriever
 
 - 
getBeginTimepublic long getBeginTime() - Specified by:
- getBeginTimein interface- Retriever
 
 - 
setBeginTimepublic void setBeginTime(long beginTime) - Specified by:
- setBeginTimein interface- Retriever
 
 - 
getEndTimepublic long getEndTime() - Specified by:
- getEndTimein interface- Retriever
 
 - 
setEndTimepublic void setEndTime(long endTime) - Specified by:
- setEndTimein interface- Retriever
 
 - 
callpublic final Retriever call() throws java.lang.Exception - Specified by:
- callin interface- java.util.concurrent.Callable<Retriever>
- Throws:
- java.lang.Exception
 
 - 
setStateprotected void setState(java.lang.String state) 
 - 
interruptedprotected boolean interrupted() 
 - 
openConnectionprotected java.net.URLConnection openConnection() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
configureSSLContextprotected void configureSSLContext(javax.net.ssl.HttpsURLConnection connection) 
 - 
endprotected void end() throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
readprotected java.nio.ByteBuffer read() throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
doReadprotected 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- connectionis null or an exception occurs during reading.
- java.lang.IllegalArgumentException- if- connectionis null
 
 - 
readNonSpecificStreamprotected java.nio.ByteBuffer readNonSpecificStream(java.io.InputStream inputStream, java.net.URLConnection connection) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
readNonSpecificStreamUnknownLengthprotected java.nio.ByteBuffer readNonSpecificStreamUnknownLength(java.io.InputStream inputStream) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
readZipStreamprotected 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- inputStreamis null
 
 - 
getExpirationprotected 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.
 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-