public class DefaultResourceRetriever extends Object implements IAdvancedResourceRetriever
IResourceRetriever interface, which can set a limit
on the size of retrieved resources using input stream with a limit on the number of bytes read.| Constructor and Description |
|---|
DefaultResourceRetriever()
Creates a new
DefaultResourceRetriever instance. |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
get(URL url,
byte[] request,
Map<String,String> headers)
Gets the
InputStream with the data from a provided URL by instantiating an HTTP connection to the URL. |
byte[] |
getByteArrayByUrl(URL url)
Gets the byte array with the data from a provided URL by instantiating an HTTP connection to the URL.
|
int |
getConnectTimeout()
Gets the connect timeout.
|
InputStream |
getInputStreamByUrl(URL url)
Gets the
InputStream with the data from a provided URL by instantiating an HTTP connection to the URL. |
int |
getReadTimeout()
Gets the read timeout.
|
Map<String,String> |
getRequestHeaders()
Gets the request headers to use in the request.
|
long |
getResourceSizeByteLimit()
Gets the resource size byte limit.
|
IResourceRetriever |
setConnectTimeout(int connectTimeout)
Sets the connect timeout.
|
IResourceRetriever |
setReadTimeout(int readTimeout)
Sets the read timeout.
|
void |
setRequestHeaders(Map<String,String> headers)
Sets the request headers to use in the request.
|
IResourceRetriever |
setResourceSizeByteLimit(long resourceSizeByteLimit)
Sets the resource size byte limit.
|
protected boolean |
urlFilter(URL url)
Method for filtering resources by URL.
|
public DefaultResourceRetriever()
DefaultResourceRetriever instance.
The limit on the size of retrieved resources is by default equal to Long.MAX_VALUE bytes.public long getResourceSizeByteLimit()
The resourceSizeByteLimit is used to create input stream with a limit on the number of bytes read.
public IResourceRetriever setResourceSizeByteLimit(long resourceSizeByteLimit)
The resourceSizeByteLimit is used to create input stream with a limit on the number of bytes read.
resourceSizeByteLimit - the resource size byte limitIResourceRetriever instancepublic int getConnectTimeout()
The connect timeout is used to create input stream with a limited time to establish connection to resource.
public IResourceRetriever setConnectTimeout(int connectTimeout)
The connect timeout is used to create input stream with a limited time to establish connection to resource.
connectTimeout - the connect timeout in millisecondsIResourceRetriever instancepublic Map<String,String> getRequestHeaders()
public void setRequestHeaders(Map<String,String> headers)
headers - the request headers to use in the requestpublic int getReadTimeout()
The read timeout is used to create input stream with a limited time to receive data from resource.
public IResourceRetriever setReadTimeout(int readTimeout)
The read timeout is used to create input stream with a limited time to receive data from resource.
readTimeout - the read timeout in millisecondsIResourceRetriever instancepublic InputStream getInputStreamByUrl(URL url) throws IOException
InputStream with the data from a provided URL by instantiating an HTTP connection to the URL.getInputStreamByUrl in interface IResourceRetrieverurl - the source URLIOException - if any input/output issue occurspublic byte[] getByteArrayByUrl(URL url) throws IOException
getByteArrayByUrl in interface IResourceRetrieverurl - the source URLIOException - if any input/output issue occurspublic InputStream get(URL url, byte[] request, Map<String,String> headers) throws IOException
InputStream with the data from a provided URL by instantiating an HTTP connection to the URL.get in interface IAdvancedResourceRetrieverurl - the source URLrequest - data to send to the URLheaders - HTTP headers to set for the outgoing connectionIOException - if any input/output issue occursprotected boolean urlFilter(URL url)
The default implementation allows for all URLs. Override this method if want to set filtering.
url - the source URLCopyright © 1998–2026 Apryse Group NV. All rights reserved.