Package org.jboss.netty.channel
Class DefaultFileRegion
java.lang.Object
org.jboss.netty.channel.DefaultFileRegion
- All Implemented Interfaces:
FileRegion
,ExternalResourceReleasable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final FileChannel
private static final InternalLogger
private final long
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFileRegion
(FileChannel file, long position, long count) DefaultFileRegion
(FileChannel file, long position, long count, boolean releaseAfterTransfer) -
Method Summary
Modifier and TypeMethodDescriptionlong
getCount()
Returns the number of bytes to transfer.long
Returns the offset in the file where the transfer began.boolean
void
Releases the external resources that this object depends on.long
transferTo
(WritableByteChannel target, long position) Transfers the content of this file region to the specified channel.
-
Field Details
-
logger
-
file
-
position
private final long position -
count
private final long count -
releaseAfterTransfer
private final boolean releaseAfterTransfer
-
-
Constructor Details
-
DefaultFileRegion
-
DefaultFileRegion
-
-
Method Details
-
getPosition
public long getPosition()Description copied from interface:FileRegion
Returns the offset in the file where the transfer began.- Specified by:
getPosition
in interfaceFileRegion
-
getCount
public long getCount()Description copied from interface:FileRegion
Returns the number of bytes to transfer.- Specified by:
getCount
in interfaceFileRegion
-
releaseAfterTransfer
public boolean releaseAfterTransfer() -
transferTo
Description copied from interface:FileRegion
Transfers the content of this file region to the specified channel.- Specified by:
transferTo
in interfaceFileRegion
- Parameters:
target
- the destination of the transferposition
- the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start fromFileRegion.getPosition()
th byte andFileRegion.getCount()
- 1 will make the last byte of the region transferred.- Throws:
IOException
-
releaseExternalResources
public void releaseExternalResources()Description copied from interface:ExternalResourceReleasable
Releases the external resources that this object depends on. You should not call this method if the external resources (e.g. thread pool) are in use by other objects.- Specified by:
releaseExternalResources
in interfaceExternalResourceReleasable
-