Class DefaultResourceRetriever
java.lang.Object
com.itextpdf.io.resolver.resource.DefaultResourceRetriever
- All Implemented Interfaces:
-
IAdvancedResourceRetriever,IResourceRetriever
Default implementation of the
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets theInputStreamwith 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.intGets the connect timeout.getInputStreamByUrl(URL url) Gets theInputStreamwith the data from a provided URL by instantiating an HTTP connection to the URL.intGets the read timeout.Gets the request headers to use in the request.longGets the resource size byte limit.setConnectTimeout(int connectTimeout) Sets the connect timeout.setReadTimeout(int readTimeout) Sets the read timeout.voidsetRequestHeaders(Map<String, String> headers) Sets the request headers to use in the request.setResourceSizeByteLimit(long resourceSizeByteLimit) Sets the resource size byte limit.protected booleanMethod for filtering resources by URL.
-
Constructor Details
-
DefaultResourceRetriever
public DefaultResourceRetriever()Creates a newDefaultResourceRetrieverinstance. The limit on the size of retrieved resources is by default equal toLong.MAX_VALUEbytes.
-
-
Method Details
-
getResourceSizeByteLimit
public long getResourceSizeByteLimit()Gets the resource size byte limit.The resourceSizeByteLimit is used to create input stream with a limit on the number of bytes read.
- Returns:
- the resource size byte limit
-
setResourceSizeByteLimit
Sets the resource size byte limit.The resourceSizeByteLimit is used to create input stream with a limit on the number of bytes read.
- Parameters:
-
resourceSizeByteLimit- the resource size byte limit - Returns:
-
the
IResourceRetrieverinstance
-
getConnectTimeout
public int getConnectTimeout()Gets the connect timeout.The connect timeout is used to create input stream with a limited time to establish connection to resource.
- Returns:
- the connect timeout in milliseconds
-
setConnectTimeout
Sets the connect timeout.The connect timeout is used to create input stream with a limited time to establish connection to resource.
- Parameters:
-
connectTimeout- the connect timeout in milliseconds - Returns:
-
the
IResourceRetrieverinstance
-
getRequestHeaders
Gets the request headers to use in the request.- Returns:
- the request headers to use in the request
-
setRequestHeaders
Sets the request headers to use in the request.- Parameters:
-
headers- the request headers to use in the request
-
getReadTimeout
public int getReadTimeout()Gets the read timeout.The read timeout is used to create input stream with a limited time to receive data from resource.
- Returns:
- the read timeout in milliseconds
-
setReadTimeout
Sets the read timeout.The read timeout is used to create input stream with a limited time to receive data from resource.
- Parameters:
-
readTimeout- the read timeout in milliseconds - Returns:
-
the
IResourceRetrieverinstance
-
getInputStreamByUrl
Gets theInputStreamwith the data from a provided URL by instantiating an HTTP connection to the URL.- Specified by:
-
getInputStreamByUrlin interfaceIResourceRetriever - Parameters:
-
url- the source URL - Returns:
- the input stream with the retrieved data
- Throws:
-
IOException- if any input/output issue occurs
-
getByteArrayByUrl
Gets the byte array with the data from a provided URL by instantiating an HTTP connection to the URL.- Specified by:
-
getByteArrayByUrlin interfaceIResourceRetriever - Parameters:
-
url- the source URL - Returns:
- the byte array with the retrieved data
- Throws:
-
IOException- if any input/output issue occurs
-
get
Gets theInputStreamwith the data from a provided URL by instantiating an HTTP connection to the URL.- Specified by:
-
getin interfaceIAdvancedResourceRetriever - Parameters:
-
url- the source URL -
request- data to send to the URL -
headers- HTTP headers to set for the outgoing connection - Returns:
- the input stream with the retrieved data
- Throws:
-
IOException- if any input/output issue occurs
-
urlFilter
Method for filtering resources by URL.The default implementation allows for all URLs. Override this method if want to set filtering.
- Parameters:
-
url- the source URL - Returns:
- true if the resource can be retrieved and false otherwise
-