LazyResource

class LazyResource(resourceProvider: LazyResourceProvider, cachedSize: Long, zipEntryName: String, href: String = zipEntryName) : Resource(source)

A Resource that loads its bytes only on-demand from an EPUB file.

zipEntryName is the resource's full path within the archive and is used as the lookup key. It is kept separate from href, which the package-document reader rewrites to be relative to the OPF.

The data is loaded on the first call that requires it, and can be released via close.

Constructors

Link copied to clipboard
constructor(resourceProvider: LazyResourceProvider, cachedSize: Long, zipEntryName: String, href: String = zipEntryName)
constructor(resourceProvider: LazyResourceProvider, href: String)

Properties

Link copied to clipboard
open override var data: ByteArray?
Link copied to clipboard
var href: String?
Link copied to clipboard
var id: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val size: Long

Functions

Link copied to clipboard

Returns the resource's bytes decoded as a String using the resource's inputEncoding.

Link copied to clipboard
open fun bytes(): ByteArray

Returns the resource's bytes (loading them if lazy).

Link copied to clipboard
open override fun close()

Tells this resource to release its cached data.

Link copied to clipboard
open fun source(): Source

Gets the contents of the Resource as an okio Source.