Class FileResourceFactory
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.FileResourceFactory
-
- All Implemented Interfaces:
ResourceFactory
@Contract(threading=STATELESS) public class FileResourceFactory extends java.lang.Object implements ResourceFactory
GeneratesResourceinstances whose body is stored in a temporary file.- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilecacheDir
-
Constructor Summary
Constructors Constructor Description FileResourceFactory(java.io.File cacheDir)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Resourcecopy(java.lang.String requestId, Resource resource)Deprecated.Do not use.Resourcegenerate(java.lang.String requestId, byte[] content)Creates aResourcefrom a given response body.Resourcegenerate(java.lang.String requestId, byte[] content, int off, int len)Creates aResourcefrom a given response body.Resourcegenerate(java.lang.String requestId, java.lang.String eTag, byte[] content, int off, int len)Creates aResourcefrom a given response body.(package private) static java.lang.StringgenerateUniqueCacheFileName(java.lang.String requestId, java.lang.String eTag, byte[] content, int off, int len)
-
-
-
Method Detail
-
generateUniqueCacheFileName
static java.lang.String generateUniqueCacheFileName(java.lang.String requestId, java.lang.String eTag, byte[] content, int off, int len)
-
generate
public Resource generate(java.lang.String requestId, java.lang.String eTag, byte[] content, int off, int len) throws ResourceIOException
Description copied from interface:ResourceFactoryCreates aResourcefrom a given response body.- Specified by:
generatein interfaceResourceFactory- Parameters:
requestId- a unique identifier for this particular response body.eTag- eTag Strong (unique) identifier for the resource entity with the given requestId, ornullwhen not given or is weak (non-unique).content- byte array that represents the origin HTTP response body.off- the start offset in the array.len- the number of bytes to read from the array.- Returns:
- a
Resourcecontaining however much of the response body was successfully read. - Throws:
ResourceIOException- Since:
- 5.4
-
generate
public Resource generate(java.lang.String requestId, byte[] content, int off, int len) throws ResourceIOException
Description copied from interface:ResourceFactoryCreates aResourcefrom a given response body.- Specified by:
generatein interfaceResourceFactory- Parameters:
requestId- a unique identifier for this particular response body.content- byte array that represents the origin HTTP response body.off- the start offset in the array.len- the number of bytes to read from the array.- Returns:
- a
Resourcecontaining however much of the response body was successfully read. - Throws:
ResourceIOException
-
generate
public Resource generate(java.lang.String requestId, byte[] content) throws ResourceIOException
Description copied from interface:ResourceFactoryCreates aResourcefrom a given response body.- Specified by:
generatein interfaceResourceFactory- Parameters:
requestId- a unique identifier for this particular response body.content- byte array that represents the origin HTTP response body.- Returns:
- a
Resourcecontaining however much of the response body was successfully read. - Throws:
ResourceIOException
-
copy
@Deprecated public Resource copy(java.lang.String requestId, Resource resource) throws ResourceIOException
Deprecated.Do not use.- Specified by:
copyin interfaceResourceFactory- Throws:
ResourceIOException
-
-