001
014
015 package com.liferay.portal.kernel.nio;
016
017 import com.liferay.portal.kernel.test.ReflectionTestUtil;
018
019 import java.io.IOException;
020
021 import java.nio.ByteBuffer;
022 import java.nio.MappedByteBuffer;
023 import java.nio.channels.FileChannel;
024 import java.nio.channels.FileLock;
025 import java.nio.channels.ReadableByteChannel;
026 import java.nio.channels.WritableByteChannel;
027
028
031 public class FileChannelWrapper extends FileChannel {
032
033 public FileChannelWrapper(FileChannel fileChannel) {
034 _fileChannel = fileChannel;
035 }
036
037 @Override
038 public void force(boolean metaData) throws IOException {
039 _fileChannel.force(metaData);
040 }
041
042 @Override
043 public FileLock lock(long position, long size, boolean shared)
044 throws IOException {
045
046 return _fileChannel.lock(position, size, shared);
047 }
048
049 @Override
050 public MappedByteBuffer map(MapMode mapMode, long position, long size)
051 throws IOException {
052
053 return _fileChannel.map(mapMode, position, size);
054 }
055
056 @Override
057 public long position() throws IOException {
058 return _fileChannel.position();
059 }
060
061 @Override
062 public FileChannel position(long newPosition) throws IOException {
063 _fileChannel.position(newPosition);
064
065 return this;
066 }
067
068 @Override
069 public int read(ByteBuffer byteBuffer) throws IOException {
070 return _fileChannel.read(byteBuffer);
071 }
072
073 @Override
074 public int read(ByteBuffer byteBuffer, long position) throws IOException {
075 return _fileChannel.read(byteBuffer, position);
076 }
077
078 @Override
079 public long read(ByteBuffer[] byteBuffers, int offset, int length)
080 throws IOException {
081
082 return _fileChannel.read(byteBuffers, offset, length);
083 }
084
085 @Override
086 public long size() throws IOException {
087 return _fileChannel.size();
088 }
089
090 @Override
091 public long transferFrom(
092 ReadableByteChannel readableByteChannel, long position, long count)
093 throws IOException {
094
095 return _fileChannel.transferFrom(readableByteChannel, position, count);
096 }
097
098 @Override
099 public long transferTo(
100 long position, long count, WritableByteChannel target)
101 throws IOException {
102
103 return _fileChannel.transferTo(position, count, target);
104 }
105
106 @Override
107 public FileChannel truncate(long size) throws IOException {
108 _fileChannel.truncate(size);
109
110 return this;
111 }
112
113 @Override
114 public FileLock tryLock(long position, long size, boolean shared)
115 throws IOException {
116
117 return _fileChannel.tryLock(position, size, shared);
118 }
119
120 @Override
121 public int write(ByteBuffer byteBuffer) throws IOException {
122 return _fileChannel.write(byteBuffer);
123 }
124
125 @Override
126 public int write(ByteBuffer byteBuffer, long position) throws IOException {
127 return _fileChannel.write(byteBuffer, position);
128 }
129
130 @Override
131 public long write(ByteBuffer[] byteBuffers, int offset, int length)
132 throws IOException {
133
134 return _fileChannel.write(byteBuffers, offset, length);
135 }
136
137 @Override
138 protected void implCloseChannel() {
139 ReflectionTestUtil.invoke(
140 _fileChannel, "implCloseChannel", new Class<?>[0]);
141 }
142
143 private final FileChannel _fileChannel;
144
145 }