Package org.jboss.netty.channel
Class DefaultFileRegion
- java.lang.Object
-
- org.jboss.netty.channel.DefaultFileRegion
-
- All Implemented Interfaces:
FileRegion,ExternalResourceReleasable
public class DefaultFileRegion extends java.lang.Object implements FileRegion
-
-
Field Summary
Fields Modifier and Type Field Description private longcountprivate java.nio.channels.FileChannelfileprivate static InternalLoggerloggerprivate longpositionprivate booleanreleaseAfterTransfer
-
Constructor Summary
Constructors Constructor Description DefaultFileRegion(java.nio.channels.FileChannel file, long position, long count)DefaultFileRegion(java.nio.channels.FileChannel file, long position, long count, boolean releaseAfterTransfer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Returns the number of bytes to transfer.longgetPosition()Returns the offset in the file where the transfer began.booleanreleaseAfterTransfer()voidreleaseExternalResources()Releases the external resources that this object depends on.longtransferTo(java.nio.channels.WritableByteChannel target, long position)Transfers the content of this file region to the specified channel.
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
file
private final java.nio.channels.FileChannel file
-
position
private final long position
-
count
private final long count
-
releaseAfterTransfer
private final boolean releaseAfterTransfer
-
-
Method Detail
-
getPosition
public long getPosition()
Description copied from interface:FileRegionReturns the offset in the file where the transfer began.- Specified by:
getPositionin interfaceFileRegion
-
getCount
public long getCount()
Description copied from interface:FileRegionReturns the number of bytes to transfer.- Specified by:
getCountin interfaceFileRegion
-
releaseAfterTransfer
public boolean releaseAfterTransfer()
-
transferTo
public long transferTo(java.nio.channels.WritableByteChannel target, long position) throws java.io.IOExceptionDescription copied from interface:FileRegionTransfers the content of this file region to the specified channel.- Specified by:
transferToin 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:
java.io.IOException
-
releaseExternalResources
public void releaseExternalResources()
Description copied from interface:ExternalResourceReleasableReleases 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:
releaseExternalResourcesin interfaceExternalResourceReleasable
-
-