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

## Class HttpByteArrayCacheEntrySerializer

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

- All Implemented Interfaces:
    HttpCacheEntrySerializer<byte[]>

      @Experimental
      public class HttpByteArrayCacheEntrySerializer
      extends Object
      implements HttpCacheEntrySerializer<byte[]>

  Cache serializer and deserializer that uses an HTTP-like format. Existing libraries for reading and writing HTTP are used, and metadata is encoded into HTTP pseudo-headers for storage.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static HttpByteArrayCacheEntrySerializer` | `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpByteArrayCacheEntrySerializer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpCacheStorageEntry` | `deserialize(byte[] serializedObject)` Deserializes a cache entry from its serialized representation.
    `protected InputStream` | `makeByteArrayInputStream(byte[] bytes)` Helper method to make a new ByteArrayInputStream.
    `protected org.apache.hc.core5.http.impl.io.AbstractMessageParser<org.apache.hc.core5.http.ClassicHttpResponse>` | `makeHttpResponseParser()` Helper method to make a new HTTP Response parser.
    `protected org.apache.hc.core5.http.impl.io.AbstractMessageWriter<SimpleHttpResponse>` | `makeHttpResponseWriter(org.apache.hc.core5.http.io.SessionOutputBuffer outputBuffer)` Helper method to make a new HTTP response writer.
    `byte[]` | `serialize(HttpCacheStorageEntry httpCacheEntry)` Serializes the given entry.

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

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

- - ### Field Detail

    - #### INSTANCE

          public static final HttpByteArrayCacheEntrySerializer INSTANCE

  - ### Constructor Detail

    - #### HttpByteArrayCacheEntrySerializer

          public HttpByteArrayCacheEntrySerializer()

  - ### Method Detail

    - #### serialize

          public byte[] serialize(HttpCacheStorageEntry httpCacheEntry)
                           throws ResourceIOException

      Description copied from interface: `HttpCacheEntrySerializer`
      Serializes the given entry.
      Specified by:
        `serialize` in interface `HttpCacheEntrySerializer<byte[]>`
      Parameters:
        `httpCacheEntry` - cache entry
      Returns:
        serialized representation of the cache entry
      Throws:
        `ResourceIOException`

    - #### deserialize

          public HttpCacheStorageEntry deserialize(byte[] serializedObject)
                                            throws ResourceIOException

      Description copied from interface: `HttpCacheEntrySerializer`
      Deserializes a cache entry from its serialized representation.
      Specified by:
        `deserialize` in interface `HttpCacheEntrySerializer<byte[]>`
      Parameters:
        `serializedObject` - serialized representation of the cache entry
      Returns:
        cache entry
      Throws:
        `ResourceIOException`

    - #### makeHttpResponseWriter

          protected org.apache.hc.core5.http.impl.io.AbstractMessageWriter<SimpleHttpResponse> makeHttpResponseWriter(org.apache.hc.core5.http.io.SessionOutputBuffer outputBuffer)

      Helper method to make a new HTTP response writer.

      Useful to override for testing.

      Parameters:
        `outputBuffer` - Output buffer to write to
      Returns:
        HTTP response writer to write to

    - #### makeByteArrayInputStream

          protected InputStream makeByteArrayInputStream(byte[] bytes)

      Helper method to make a new ByteArrayInputStream.

      Useful to override for testing.

      Parameters:
        `bytes` - Bytes to read from the stream
      Returns:
        Stream to read the bytes from

    - #### makeHttpResponseParser

          protected org.apache.hc.core5.http.impl.io.AbstractMessageParser<org.apache.hc.core5.http.ClassicHttpResponse> makeHttpResponseParser()

      Helper method to make a new HTTP Response parser.

      Useful to override for testing.

      Returns:
        HTTP response parser

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