org.apache.hc.client5.http.impl.cache

## Class FileResourceFactory

- java.lang.Object
- - org.apache.hc.client5.http.impl.cache.FileResourceFactory

- All Implemented Interfaces:
    ResourceFactory

      @Contract(threading=STATELESS)
      public class FileResourceFactory
      extends Object
      implements ResourceFactory

  Generates `Resource` instances whose body is stored in a temporary file.
  Since:
    4.1

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileResourceFactory(File cacheDir)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `Resource` | `copy(String requestId, Resource resource)` Deprecated. Do not use.
    `Resource` | `generate(String requestId, byte[] content)` Creates a `Resource` from a given response body.
    `Resource` | `generate(String requestId, byte[] content, int off, int len)` Creates a `Resource` from a given response body.
    `Resource` | `generate(String requestId, String eTag, byte[] content, int off, int len)` Creates a `Resource` from a given response body.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileResourceFactory

          public FileResourceFactory(File cacheDir)

  - ### Method Detail

    - #### generate

          public Resource generate(String requestId,
                                   String eTag,
                                   byte[] content,
                                   int off,
                                   int len)
                            throws ResourceIOException

      Description copied from interface: `ResourceFactory`
      Creates a `Resource` from a given response body.
      Specified by:
        `generate` in interface `ResourceFactory`
      Parameters:
        `requestId` - a unique identifier for this particular response body.
        `eTag` - eTag Strong (unique) identifier for the resource entity with the given requestId, or `null` when 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 `Resource` containing however much of the response body was successfully read.
      Throws:
        `ResourceIOException`
      Since:
        5.4

    - #### generate

          public Resource generate(String requestId,
                                   byte[] content,
                                   int off,
                                   int len)
                            throws ResourceIOException

      Description copied from interface: `ResourceFactory`
      Creates a `Resource` from a given response body.
      Specified by:
        `generate` in interface `ResourceFactory`
      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 `Resource` containing however much of the response body was successfully read.
      Throws:
        `ResourceIOException`

    - #### generate

          public Resource generate(String requestId,
                                   byte[] content)
                            throws ResourceIOException

      Description copied from interface: `ResourceFactory`
      Creates a `Resource` from a given response body.
      Specified by:
        `generate` in interface `ResourceFactory`
      Parameters:
        `requestId` - a unique identifier for this particular response body.
        `content` - byte array that represents the origin HTTP response body.
      Returns:
        a `Resource` containing however much of the response body was successfully read.
      Throws:
        `ResourceIOException`

    - #### copy

          @Deprecated
          public Resource copy(String requestId,
                                           Resource resource)
                                    throws ResourceIOException

      Deprecated. Do not use.
      Specified by:
        `copy` in interface `ResourceFactory`
      Throws:
        `ResourceIOException`

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.