C# Class nl.siegmann.epublib.domain.Resource

Exibir arquivo Open project: lanfengqi/EpubLib-Sharp Class Usage Examples

Public Methods

Method Description
Resource ( System stream, string href ) : System

Creates a resource with the data from the given InputStream at the specified href. The MediaType will be determined based on the href extension.

Resource ( byte data, MediaType mediaType ) : System

Creates a Resource with the given data and MediaType. The href will be automatically generated. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8

Resource ( byte data, string href ) : System

Creates a resource with the given data at the specified href. The MediaType will be determined based on the href extension. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8

Resource ( string href ) : System

Creates an empty Resource with the given href. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8

Resource ( string id, byte data, string href, MediaType mediaType ) : System

Creates a resource with the given id, data, mediatype at the specified href. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8

Resource ( string id, byte data, string href, MediaType mediaType, string inputEncoding ) : System

Creates a resource with the given id, data, mediatype at the specified href. If the data is of a text type (html/css/etc) then it will use the given inputEncoding.

Resource ( string fileName, long size, string href ) : System

Creates a Lazy resource, by not actually loading the data for this entry. The data will be loaded on the first call to getData()

close ( ) : void

Tells this resource to release its cached data. If this resource was not lazy- loaded, this is a no-op.

equals ( Object resourceObject ) : bool

Checks to see of the given resourceObject is a resource and whether its href is equal to this one.

getData ( ) : byte[]

The contents of the resource as a byte[] If this resource was lazy-loaded and the data was not yet loaded, it will be loaded into memory at this point. This included opening the zip file, so expect a first load to be slow.

getHref ( ) : string

The location of the resource within the contents folder of the epub file. Example:
images/cover.jpg
content/chapter1.xhtml

getId ( ) : string

The resources Id. Must be both unique within all the resources of this book and a valid identifier.

getInputEncoding ( ) : string

The character encoding of the resource. Is allowed to be null for non-text resources like images.

getInputStream ( ) : Stream

Gets the contents of the Resource as an InputStream.

getMediaType ( ) : MediaType

This resource's mediaType.

getSize ( ) : long

Returns the size of this resource in bytes.

getTitle ( ) : string

If the title is found by scanning the underlying html document then it is cached here.

hashCode ( ) : int

Gets the hashCode of the Resource's href.

isInitialized ( ) : bool

Returns if the data for this resource has been loaded into memory.

setData ( byte data ) : void

Sets the data of the Resource. If the data is a of a different type then the original data then make sure to change the MediaType.

setHref ( string href ) : void

Sets the Resource's href.

setId ( string id ) : void

Sets the Resource's id: Make sure it is unique and a valid identifier.

setInputEncoding ( string encoding ) : void

Sets the Resource's input character encoding.

setMediaType ( MediaType mediaType ) : void
setTitle ( string title ) : void
toString ( ) : string

Method Details

Resource() public method

Creates a resource with the data from the given InputStream at the specified href. The MediaType will be determined based on the href extension.
public Resource ( System stream, string href ) : System
stream System
href string The location of the resource within the epub. Example: /// "cover.jpg".
return System

Resource() public method

Creates a Resource with the given data and MediaType. The href will be automatically generated. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8
public Resource ( byte data, MediaType mediaType ) : System
data byte The Resource's contents
mediaType MediaType The MediaType of the Resource
return System

Resource() public method

Creates a resource with the given data at the specified href. The MediaType will be determined based on the href extension. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8
public Resource ( byte data, string href ) : System
data byte The Resource's contents
href string The location of the resource within the epub. Example: /// "chapter1.html".
return System

Resource() public method

Creates an empty Resource with the given href. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8
public Resource ( string href ) : System
href string The location of the resource within the epub. Example: /// "chapter1.html".
return System

Resource() public method

Creates a resource with the given id, data, mediatype at the specified href. Assumes that if the data is of a text type (html/css/etc) then the encoding will be UTF-8
public Resource ( string id, byte data, string href, MediaType mediaType ) : System
id string The id of the Resource. Internal use only. Will be auto- /// generated if it has a null-value.
data byte The Resource's contents
href string The location of the resource within the epub. Example: /// "chapter1.html".
mediaType MediaType The resources MediaType
return System

Resource() public method

Creates a resource with the given id, data, mediatype at the specified href. If the data is of a text type (html/css/etc) then it will use the given inputEncoding.
public Resource ( string id, byte data, string href, MediaType mediaType, string inputEncoding ) : System
id string The id of the Resource. Internal use only. Will be auto- /// generated if it has a null-value.
data byte The Resource's contents
href string The location of the resource within the epub. Example: /// "chapter1.html".
mediaType MediaType The resources MediaType
inputEncoding string If the data is of a text type (html/css/etc) then /// it will use the given inputEncoding.
return System

Resource() public method

Creates a Lazy resource, by not actually loading the data for this entry. The data will be loaded on the first call to getData()
public Resource ( string fileName, long size, string href ) : System
fileName string the fileName for the epub we're created from.
size long the size of this resource.
href string The resource's href within the epub.
return System

close() public method

Tells this resource to release its cached data. If this resource was not lazy- loaded, this is a no-op.
public close ( ) : void
return void

equals() public method

Checks to see of the given resourceObject is a resource and whether its href is equal to this one.
public equals ( Object resourceObject ) : bool
resourceObject Object
return bool

getData() public method

The contents of the resource as a byte[] If this resource was lazy-loaded and the data was not yet loaded, it will be loaded into memory at this point. This included opening the zip file, so expect a first load to be slow.
public getData ( ) : byte[]
return byte[]

getHref() public method

The location of the resource within the contents folder of the epub file. Example:
images/cover.jpg
content/chapter1.xhtml
public getHref ( ) : string
return string

getId() public method

The resources Id. Must be both unique within all the resources of this book and a valid identifier.
public getId ( ) : string
return string

getInputEncoding() public method

The character encoding of the resource. Is allowed to be null for non-text resources like images.
public getInputEncoding ( ) : string
return string

getInputStream() public method

Gets the contents of the Resource as an InputStream.
public getInputStream ( ) : Stream
return System.IO.Stream

getMediaType() public method

This resource's mediaType.
public getMediaType ( ) : MediaType
return MediaType

getSize() public method

Returns the size of this resource in bytes.
public getSize ( ) : long
return long

getTitle() public method

If the title is found by scanning the underlying html document then it is cached here.
public getTitle ( ) : string
return string

hashCode() public method

Gets the hashCode of the Resource's href.
public hashCode ( ) : int
return int

isInitialized() public method

Returns if the data for this resource has been loaded into memory.
public isInitialized ( ) : bool
return bool

setData() public method

Sets the data of the Resource. If the data is a of a different type then the original data then make sure to change the MediaType.
public setData ( byte data ) : void
data byte data
return void

setHref() public method

Sets the Resource's href.
public setHref ( string href ) : void
href string href
return void

setId() public method

Sets the Resource's id: Make sure it is unique and a valid identifier.
public setId ( string id ) : void
id string id
return void

setInputEncoding() public method

Sets the Resource's input character encoding.
public setInputEncoding ( string encoding ) : void
encoding string encoding
return void

setMediaType() public method

public setMediaType ( MediaType mediaType ) : void
mediaType MediaType
return void

setTitle() public method

public setTitle ( string title ) : void
title string
return void

toString() public method

public toString ( ) : string
return string