public abstract class URLRetriever extends WWObjectImpl implements Retriever
Modifier and Type | Field and Description |
---|---|
protected long |
beginTime |
protected ByteBuffer |
byteBuffer |
protected URLConnection |
connection |
protected int |
connectTimeout |
protected int |
contentLength |
protected AtomicInteger |
contentLengthRead |
protected String |
contentType |
protected long |
endTime |
protected AtomicLong |
expiration |
static String |
EXTRACT_ZIP_ENTRY
Applications never need to use this constant.
|
protected RetrievalPostProcessor |
postProcessor |
protected int |
readTimeout |
protected int |
staleRequestLimit |
protected String |
state |
protected long |
submitTime |
protected URL |
url |
RETRIEVER_STATE_CONNECTING, RETRIEVER_STATE_ERROR, RETRIEVER_STATE_INTERRUPTED, RETRIEVER_STATE_NOT_STARTED, RETRIEVER_STATE_READING, RETRIEVER_STATE_STARTED, RETRIEVER_STATE_SUCCESSFUL
Constructor and Description |
---|
URLRetriever(URL url,
RetrievalPostProcessor postProcessor) |
Modifier and Type | Method and Description |
---|---|
Retriever |
call() |
protected void |
configureSSLContext(HttpsURLConnection connection) |
static URLRetriever |
createRetriever(URL url,
RetrievalPostProcessor postProcessor)
Create the appropriate retriever for a URL's protocol.
|
protected ByteBuffer |
doRead(URLConnection connection) |
protected void |
end() |
boolean |
equals(Object o) |
long |
getBeginTime() |
ByteBuffer |
getBuffer() |
protected URLConnection |
getConnection() |
int |
getConnectTimeout() |
int |
getContentLength() |
int |
getContentLengthRead() |
String |
getContentType() |
long |
getEndTime() |
protected long |
getExpiration(URLConnection connection)
Indicates the expiration time specified by either the Expires header or the max-age directive of the
Cache-Control header.
|
long |
getExpirationTime()
Indicates the expiration time of the resource retrieved by this Retriever.
|
String |
getName() |
RetrievalPostProcessor |
getPostProcessor() |
int |
getReadTimeout() |
int |
getStaleRequestLimit() |
String |
getState() |
long |
getSubmitTime() |
URL |
getUrl() |
URL |
getURL() |
int |
hashCode() |
protected boolean |
interrupted() |
protected URLConnection |
openConnection() |
protected ByteBuffer |
read() |
protected ByteBuffer |
readNonSpecificStream(InputStream inputStream,
URLConnection connection) |
protected ByteBuffer |
readNonSpecificStreamUnknownLength(InputStream inputStream) |
protected ByteBuffer |
readZipStream(InputStream inputStream,
URL url) |
void |
setBeginTime(long beginTime) |
void |
setConnectTimeout(int connectTimeout) |
protected void |
setContentLengthRead(int length) |
void |
setEndTime(long endTime) |
void |
setReadTimeout(int readTimeout) |
void |
setStaleRequestLimit(int staleRequestLimit) |
protected void |
setState(String state) |
void |
setSubmitTime(long submitTime) |
String |
toString() |
onMessage, propertyChange
addPropertyChangeListener, 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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
propertyChange
onMessage
protected long beginTime
protected volatile ByteBuffer byteBuffer
protected volatile URLConnection connection
protected int connectTimeout
protected volatile int contentLength
protected AtomicInteger contentLengthRead
protected volatile String contentType
protected long endTime
protected AtomicLong expiration
public static final String EXTRACT_ZIP_ENTRY
protected final RetrievalPostProcessor postProcessor
protected int readTimeout
protected int staleRequestLimit
protected volatile String state
protected long submitTime
protected final URL url
public URLRetriever(URL url, RetrievalPostProcessor postProcessor)
url
- the URL of the resource to retrieve.postProcessor
- the retrieval post-processor to invoke when the resource is retrieved. May be null.IllegalArgumentException
- if url
.protected void configureSSLContext(HttpsURLConnection connection)
public static URLRetriever createRetriever(URL url, RetrievalPostProcessor postProcessor)
url
- the url that will be the source of the retrieval.postProcessor
- the retriever's post-processor.IllegalArgumentException
- if the url is null.protected ByteBuffer doRead(URLConnection connection) throws Exception
connection
- the connection to read from.Exception
- if connection
is null or an exception occurs during reading.IllegalArgumentException
- if connection
is nullpublic long getBeginTime()
getBeginTime
in interface Retriever
public final ByteBuffer getBuffer()
protected final URLConnection getConnection()
public final int getConnectTimeout()
getConnectTimeout
in interface Retriever
public final int getContentLength()
getContentLength
in interface Retriever
public final int getContentLengthRead()
getContentLengthRead
in interface Retriever
public final String getContentType()
getContentType
in interface Retriever
public long getEndTime()
getEndTime
in interface Retriever
protected long getExpiration(URLConnection connection)
connection
- Connection for which to get expiration time.public long getExpirationTime()
getExpirationTime
in interface Retriever
public final RetrievalPostProcessor getPostProcessor()
public int getReadTimeout()
getReadTimeout
in interface Retriever
public int getStaleRequestLimit()
getStaleRequestLimit
in interface Retriever
public long getSubmitTime()
getSubmitTime
in interface Retriever
public final URL getUrl()
public final URL getURL()
protected boolean interrupted()
protected URLConnection openConnection() throws IOException
IOException
protected ByteBuffer read() throws Exception
Exception
protected ByteBuffer readNonSpecificStream(InputStream inputStream, URLConnection connection) throws IOException
IOException
protected ByteBuffer readNonSpecificStreamUnknownLength(InputStream inputStream) throws IOException
IOException
protected ByteBuffer readZipStream(InputStream inputStream, URL url) throws IOException
inputStream
- a stream to the zip connection.url
- the URL of the zip resource.IOException
- if the stream does not refer to a zip resource or an exception occurs during
reading.IllegalArgumentException
- if inputStream
is nullpublic void setBeginTime(long beginTime)
setBeginTime
in interface Retriever
public final void setConnectTimeout(int connectTimeout)
setConnectTimeout
in interface Retriever
protected void setContentLengthRead(int length)
public void setEndTime(long endTime)
setEndTime
in interface Retriever
public void setReadTimeout(int readTimeout)
setReadTimeout
in interface Retriever
public void setStaleRequestLimit(int staleRequestLimit)
setStaleRequestLimit
in interface Retriever
protected void setState(String state)
public void setSubmitTime(long submitTime)
setSubmitTime
in interface Retriever