Package 

Class TransformingResource

  • All Implemented Interfaces:
    org.readium.r2.shared.fetcher.Resource , org.readium.r2.shared.util.SuspendingCloseable

    
    public abstract class TransformingResource
    extends ProxyResource
                        

    Transforms the bytes of resource on-the-fly.

    If you set cacheBytes to false, consider providing your own implementation of length to avoid unnecessary transformations.

    Warning: The transformation runs on the full content of resource, so it's not appropriate for large resources which can't be held in memory.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final File file
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Try<ByteArray, Resource.Exception> transform(Try<ByteArray, Resource.Exception> data)
      Try<ByteArray, Resource.Exception> read(LongRange range) Reads the bytes at the given range.
      Try<Long, Resource.Exception> length() Returns data length from metadata if available, or calculated from reading the bytes otherwise.
      • Methods inherited from class org.readium.r2.shared.fetcher.ProxyResource

        close, getFile, link, toString
      • Methods inherited from class org.readium.r2.shared.fetcher.Resource

        readAsBitmap, readAsJson, readAsString, readAsXml
      • Methods inherited from class java.lang.Object

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