Package 

Interface Readable

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

    
    public interface Readable
     implements SuspendingCloseable
                        

    Acts as a proxy to an actual data source by handling read access.

    • Method Summary

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

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • length

         abstract Try<Long, ReadError> length()

        Returns data length from metadata if available, or calculated from reading the bytes otherwise.

        This value must be treated as a hint, as it might not reflect the actual bytes length. To get the real length, you need to read the whole resource.

      • read

         abstract Try<ByteArray, ReadError> read(LongRange range)

        Reads the bytes at the given range.

        When range is null, the whole content is returned. Out-of-range indexes are clamped to the available length automatically.