Clean up FileRegion and its implementation changes
* Fix broken javadoc tags * Remove unnecessary public modifier * Reorder method * Make releaseAfterTransfer immutable
This commit is contained in:
parent
3b7f55dc35
commit
114ddd9a62
@ -14,7 +14,7 @@ public class DefaultFileRegion implements FileRegion {
|
||||
private final FileChannel file;
|
||||
private final long position;
|
||||
private final long count;
|
||||
private boolean releaseAfterTransfer;
|
||||
private final boolean releaseAfterTransfer;
|
||||
|
||||
public DefaultFileRegion(FileChannel file, long position, long count, boolean releaseAfterTransfer) {
|
||||
this.file = file;
|
||||
@ -24,12 +24,8 @@ public class DefaultFileRegion implements FileRegion {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #DefaultFileRegion(FileChannel, long, long, boolean)} with <code>true</code>
|
||||
* as the last argument.
|
||||
*
|
||||
* @param file
|
||||
* @param position
|
||||
* @param count
|
||||
* Calls {@link #DefaultFileRegion(FileChannel, long, long, boolean)}
|
||||
* with <code>true</code> as the last argument.
|
||||
*/
|
||||
public DefaultFileRegion(FileChannel file, long position, long count) {
|
||||
this(file, position, count, true);
|
||||
@ -46,6 +42,11 @@ public class DefaultFileRegion implements FileRegion {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean releaseAfterTransfer() {
|
||||
return releaseAfterTransfer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(WritableByteChannel target, long position) throws IOException {
|
||||
long count = this.count - position;
|
||||
@ -69,13 +70,4 @@ public class DefaultFileRegion implements FileRegion {
|
||||
logger.warn("Failed to close a file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean releaseAfterTransfer() {
|
||||
return releaseAfterTransfer;
|
||||
}
|
||||
|
||||
public void setReleaseAfterTransfer(boolean releaseAfterTransfer) {
|
||||
this.releaseAfterTransfer = releaseAfterTransfer;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,12 @@ public interface FileRegion extends ExternalResourceReleasable {
|
||||
*/
|
||||
long getCount();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if {@link #releaseExternalResources()} has to
|
||||
* be called after the transfer of this {@link FileRegion} is complete.
|
||||
*/
|
||||
boolean releaseAfterTransfer();
|
||||
|
||||
/**
|
||||
* Transfers the content of this file region to the specified channel.
|
||||
*
|
||||
@ -84,12 +90,4 @@ public interface FileRegion extends ExternalResourceReleasable {
|
||||
* byte of the region transferred.
|
||||
*/
|
||||
long transferTo(WritableByteChannel target, long position) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if {@link #releaseExternalResources()} should be called after the
|
||||
* transfer of the {@link FileRegion} was complete.
|
||||
*
|
||||
* @return release
|
||||
*/
|
||||
public boolean releaseAfterTransfer();
|
||||
}
|
Loading…
Reference in New Issue
Block a user