DefaultFileRegion

cc.otavia.core.channel.DefaultFileRegion
class DefaultFileRegion(val position: Long, val count: Long) extends AbstractReferenceCounted, FileRegion

Default FileRegion implementation which transfer data from a FileChannel or File. Be aware that the FileChannel will be automatically closed once FileRegion.refCnt returns 0.

Value parameters

count

the number of bytes to transfer

position

the position from which the transfer should start

Attributes

Graph
Supertypes
trait FileRegion
class AbstractReferenceCounted
trait ReferenceCounted
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(fileChannel: FileChannel, position: Long, count: Long)

Create a new instance

Create a new instance

Value parameters

count

the number of bytes to transfer

fileChannel

the FileChannel which should be transferred

position

the position from which the transfer should start

Attributes

def this(file: File, position: Long, count: Long)

Create a new instance using the given File. The File will be opened lazily or explicitly via open.

Create a new instance using the given File. The File will be opened lazily or explicitly via open.

Value parameters

count

the number of bytes to transfer

file

the File which should be transferred

position

the position from which the transfer should start

Attributes

def this(file: File)

Create a new instance using the given File. The File will be opened lazily or explicitly via open. The position is 0 and count is the length of the file.

Create a new instance using the given File. The File will be opened lazily or explicitly via open. The position is 0 and count is the length of the file.

Value parameters

file

the File which should be transferred

Attributes

def this(fileChannel: FileChannel)

Create a new instance using the given File. The File will be opened lazily or explicitly via open. The position is 0 and count is the size of the fileChannel.

Create a new instance using the given File. The File will be opened lazily or explicitly via open. The position is 0 and count is the size of the fileChannel.

Value parameters

file

the File which should be transferred

Attributes

Concrete methods

override def countBytes: Array[Byte]

Attributes

Definition Classes
override def isOpen: Boolean

Returns true if the FileRegion has a open file-descriptor

Returns true if the FileRegion has a open file-descriptor

Attributes

Definition Classes
def open(): Unit

Explicitly open the underlying file-descriptor if not done yet.

Explicitly open the underlying file-descriptor if not done yet.

Attributes

override def transferTo(target: WritableByteChannel, position: Long): Long

Transfers the content of this file region to the specified channel.

Transfers the content of this file region to the specified channel.

Value parameters

position

the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start from positionth byte and count - 1 will make the last byte of the region transferred.

target

the destination of the transfer

Attributes

Definition Classes
override def transferred: Long

Returns the bytes which was transferred already.

Returns the bytes which was transferred already.

Attributes

Definition Classes

Inherited methods

override def refCnt: Int

Returns the reference count of this object. If 0, it means this object has been deallocated.

Returns the reference count of this object. If 0, it means this object has been deallocated.

Attributes

Definition Classes
AbstractReferenceCounted -> ReferenceCounted
Inherited from:
AbstractReferenceCounted
override def release(decrement: Int): Boolean

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.

Value parameters

decrement

decrement reference count

Attributes

Returns

true if and only if the reference count became 0 and this object has been deallocated

Definition Classes
AbstractReferenceCounted -> ReferenceCounted
Inherited from:
AbstractReferenceCounted
override def release: Boolean

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.

Attributes

Returns

true if and only if the reference count became 0 and this object has been deallocated

Definition Classes
AbstractReferenceCounted -> ReferenceCounted
Inherited from:
AbstractReferenceCounted
override def retain(increment: Int): AbstractReferenceCounted.this.type

Increases the reference count by the specified increment.

Increases the reference count by the specified increment.

Attributes

Definition Classes
AbstractReferenceCounted -> ReferenceCounted
Inherited from:
AbstractReferenceCounted
override def retain: AbstractReferenceCounted.this.type

Increases the reference count by 1.

Increases the reference count by 1.

Attributes

Definition Classes
AbstractReferenceCounted -> ReferenceCounted
Inherited from:
AbstractReferenceCounted

Concrete fields

override val count: Long

Returns the number of bytes to transfer.

Returns the number of bytes to transfer.

Attributes

override val position: Long

Returns the offset in the file where the transfer began.

Returns the offset in the file where the transfer began.

Attributes