1 /* MappedByteBufferImpl.java --
2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java.io.IOException;
42 import java.nio.channels.FileChannelImpl;
43 import gnu.gcj.RawData;
45 public class MappedByteBufferImpl extends MappedByteBuffer
49 public FileChannelImpl ch;
51 public MappedByteBufferImpl (FileChannelImpl ch) throws IOException
53 super ((int) ch.size (), (int) ch.size (), 0, -1);
56 map_address = ch.map_address;
57 long si = ch.size () / 1;
61 public MappedByteBufferImpl (FileChannelImpl ch, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
63 super (capacity, limit, position, mark);
66 this.array_offset = offset;
67 this.readOnly = readOnly;
70 public boolean isReadOnly ()
75 public static byte getImpl (FileChannelImpl ch, int index,
76 int limit, RawData map_address)
78 throw new Error ("Not implemented");
81 public static void putImpl (FileChannelImpl ch, int index,
82 int limit, byte value, RawData map_address)
84 throw new Error ("Not implemented");
89 byte result = get (position());
90 position (position() + 1);
94 public ByteBuffer put (byte value)
96 put (position(), value);
97 position (position() + 1);
101 public byte get (int index)
103 return getImpl (ch, index, limit (), map_address);
106 public ByteBuffer put (int index, byte value)
108 putImpl (ch, index, limit (), value, map_address);
112 public ByteBuffer compact ()
114 int pos = position();
117 int count = remaining();
118 shiftDown(0, pos, count);
125 public boolean isDirect ()
130 public ByteBuffer slice ()
132 throw new Error ("Not implemented");
135 public ByteBuffer duplicate ()
137 throw new Error ("Not implemented");
140 public ByteBuffer asReadOnlyBuffer ()
142 throw new Error ("Not implemented");
145 public CharBuffer asCharBuffer ()
147 return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
150 public ShortBuffer asShortBuffer ()
152 return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
155 public IntBuffer asIntBuffer ()
157 return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
160 public LongBuffer asLongBuffer ()
162 return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
165 public FloatBuffer asFloatBuffer ()
167 return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
170 public DoubleBuffer asDoubleBuffer ()
172 return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
175 final public char getChar ()
177 return ByteBufferHelper.getChar(this, order());
180 final public ByteBuffer putChar (char value)
182 ByteBufferHelper.putChar(this, value, order());
186 final public char getChar (int index)
188 return ByteBufferHelper.getChar(this, index, order());
191 final public ByteBuffer putChar (int index, char value)
193 ByteBufferHelper.putChar(this, index, value, order());
197 final public short getShort ()
199 return ByteBufferHelper.getShort(this, order());
202 final public ByteBuffer putShort (short value)
204 ByteBufferHelper.putShort(this, value, order());
208 final public short getShort (int index)
210 return ByteBufferHelper.getShort(this, index, order());
213 final public ByteBuffer putShort (int index, short value)
215 ByteBufferHelper.putShort(this, index, value, order());
219 final public int getInt ()
221 return ByteBufferHelper.getInt(this, order());
224 final public ByteBuffer putInt (int value)
226 ByteBufferHelper.putInt(this, value, order());
230 final public int getInt (int index)
232 return ByteBufferHelper.getInt(this, index, order());
235 final public ByteBuffer putInt (int index, int value)
237 ByteBufferHelper.putInt(this, index, value, order());
241 final public long getLong ()
243 return ByteBufferHelper.getLong(this, order());
246 final public ByteBuffer putLong (long value)
248 ByteBufferHelper.putLong (this, value, order());
252 final public long getLong (int index)
254 return ByteBufferHelper.getLong (this, index, order());
257 final public ByteBuffer putLong (int index, long value)
259 ByteBufferHelper.putLong (this, index, value, order());
263 final public float getFloat ()
265 return ByteBufferHelper.getFloat (this, order());
268 final public ByteBuffer putFloat (float value)
270 ByteBufferHelper.putFloat (this, value, order());
274 public final float getFloat (int index)
276 return ByteBufferHelper.getFloat (this, index, order());
279 final public ByteBuffer putFloat (int index, float value)
281 ByteBufferHelper.putFloat (this, index, value, order());
285 final public double getDouble ()
287 return ByteBufferHelper.getDouble (this, order());
290 final public ByteBuffer putDouble (double value)
292 ByteBufferHelper.putDouble (this, value, order());
296 final public double getDouble (int index)
298 return ByteBufferHelper.getDouble (this, index, order());
301 final public ByteBuffer putDouble (int index, double value)
303 ByteBufferHelper.putDouble (this, index, value, order());