46 |
import java.nio.LongBuffer; |
import java.nio.LongBuffer; |
47 |
import java.nio.ShortBuffer; |
import java.nio.ShortBuffer; |
48 |
import java.nio.MappedByteBuffer; |
import java.nio.MappedByteBuffer; |
49 |
|
import gnu.classpath.RawData; |
50 |
|
|
51 |
final public class MappedByteFileBuffer |
final public class MappedByteFileBuffer |
52 |
extends MappedByteBuffer |
extends MappedByteBuffer |
53 |
{ |
{ |
54 |
public long address; |
public RawData map_address; |
55 |
boolean readOnly; |
boolean readOnly; |
56 |
boolean direct; |
boolean direct; |
57 |
public FileChannelImpl ch; |
public FileChannelImpl ch; |
61 |
// FIXME |
// FIXME |
62 |
super (0, 0, 0, 0); |
super (0, 0, 0, 0); |
63 |
this.ch = ch; |
this.ch = ch; |
64 |
address = ch.address; |
map_address = ch.map_address; |
65 |
} |
} |
66 |
|
|
67 |
public MappedByteFileBuffer(MappedByteFileBuffer b) |
public MappedByteFileBuffer(MappedByteFileBuffer b) |
70 |
super (0, 0, 0, 0); |
super (0, 0, 0, 0); |
71 |
this.readOnly = b.readOnly; |
this.readOnly = b.readOnly; |
72 |
this.ch = b.ch; |
this.ch = b.ch; |
73 |
address = b.address; |
map_address = b.map_address; |
74 |
} |
} |
75 |
|
|
76 |
public boolean isReadOnly () |
public boolean isReadOnly () |
77 |
{ |
{ |
78 |
return readOnly; |
return readOnly; |
79 |
} |
} |
80 |
public static native byte nio_read_Byte_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Byte_file_channel(FileChannelImpl ch, int index, int limit, byte value, long address); |
public static native byte nio_read_Byte_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Byte_file_channel(FileChannelImpl ch, int index, int limit, byte value, RawData address); |
81 |
public static native short nio_read_Short_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Short_file_channel(FileChannelImpl ch, int index, int limit, short value, long address); |
public static native short nio_read_Short_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Short_file_channel(FileChannelImpl ch, int index, int limit, short value, RawData address); |
82 |
public static native char nio_read_Char_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Char_file_channel(FileChannelImpl ch, int index, int limit, char value, long address); |
public static native char nio_read_Char_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Char_file_channel(FileChannelImpl ch, int index, int limit, char value, RawData address); |
83 |
public static native int nio_read_Int_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Int_file_channel(FileChannelImpl ch, int index, int limit, int value, long address); |
public static native int nio_read_Int_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Int_file_channel(FileChannelImpl ch, int index, int limit, int value, RawData address); |
84 |
public static native long nio_read_Long_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Long_file_channel(FileChannelImpl ch, int index, int limit, long value, long address); |
public static native long nio_read_Long_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Long_file_channel(FileChannelImpl ch, int index, int limit, long value, RawData address); |
85 |
public static native float nio_read_Float_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Float_file_channel(FileChannelImpl ch, int index, int limit, float value, long address); |
public static native float nio_read_Float_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Float_file_channel(FileChannelImpl ch, int index, int limit, float value, RawData address); |
86 |
public static native double nio_read_Double_file_channel(FileChannelImpl ch, int index, int limit, long address); public static native void nio_write_Double_file_channel(FileChannelImpl ch, int index, int limit, double value, long address); |
public static native double nio_read_Double_file_channel(FileChannelImpl ch, int index, int limit, RawData address); public static native void nio_write_Double_file_channel(FileChannelImpl ch, int index, int limit, double value, RawData address); |
87 |
|
|
88 |
final public byte get() |
final public byte get() |
89 |
{ |
{ |
90 |
byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address); |
byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), map_address); |
91 |
position(position() + 1); |
position(position() + 1); |
92 |
return a; |
return a; |
93 |
} |
} |
94 |
|
|
95 |
final public ByteBuffer put(byte b) |
final public ByteBuffer put(byte b) |
96 |
{ |
{ |
97 |
MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), b, address); |
MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), b, map_address); |
98 |
position(position() + 1); |
position(position() + 1); |
99 |
return this; |
return this; |
100 |
} |
} |
101 |
|
|
102 |
final public byte get(int index) |
final public byte get(int index) |
103 |
{ |
{ |
104 |
byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address); |
byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), map_address); |
105 |
return a; |
return a; |
106 |
} |
} |
107 |
|
|
108 |
final public ByteBuffer put(int index, byte b) |
final public ByteBuffer put(int index, byte b) |
109 |
{ |
{ |
110 |
MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), b, address); |
MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), b, map_address); |
111 |
return this; |
return this; |
112 |
} |
} |
113 |
|
|
139 |
return b; |
return b; |
140 |
} |
} |
141 |
|
|
142 |
final public ByteBuffer asByteBuffer() { ByteBuffer res = new MappedByteFileBuffer(ch); res.limit((limit()*1)/1); return res; } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), value, address); return this; }; |
final public ByteBuffer asByteBuffer() { ByteBuffer res = new MappedByteFileBuffer(ch); res.limit((limit()*1)/1); return res; } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), value, map_address); return this; }; |
143 |
final public CharBuffer asCharBuffer() { CharBuffer res = new MappedCharFileBuffer(ch); res.limit((limit()*1)/2); return res; } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, limit(), value, address); return this; }; |
final public CharBuffer asCharBuffer() { CharBuffer res = new MappedCharFileBuffer(ch); res.limit((limit()*1)/2); return res; } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, limit(), value, map_address); return this; }; |
144 |
final public ShortBuffer asShortBuffer() { ShortBuffer res = new MappedShortFileBuffer(ch); res.limit((limit()*1)/2); return res; } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, limit(), value, address); return this; }; |
final public ShortBuffer asShortBuffer() { ShortBuffer res = new MappedShortFileBuffer(ch); res.limit((limit()*1)/2); return res; } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, limit(), value, map_address); return this; }; |
145 |
final public IntBuffer asIntBuffer() { IntBuffer res = new MappedIntFileBuffer(ch); res.limit((limit()*1)/4); return res; } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, limit(), value, address); return this; }; |
final public IntBuffer asIntBuffer() { IntBuffer res = new MappedIntFileBuffer(ch); res.limit((limit()*1)/4); return res; } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, limit(), value, map_address); return this; }; |
146 |
final public LongBuffer asLongBuffer() { LongBuffer res = new MappedLongFileBuffer(ch); res.limit((limit()*1)/8); return res; } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, limit(), value, address); return this; }; |
final public LongBuffer asLongBuffer() { LongBuffer res = new MappedLongFileBuffer(ch); res.limit((limit()*1)/8); return res; } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, limit(), value, map_address); return this; }; |
147 |
final public FloatBuffer asFloatBuffer() { FloatBuffer res = new MappedFloatFileBuffer(ch); res.limit((limit()*1)/4); return res; } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, limit(), value, address); return this; }; |
final public FloatBuffer asFloatBuffer() { FloatBuffer res = new MappedFloatFileBuffer(ch); res.limit((limit()*1)/4); return res; } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, limit(), value, map_address); return this; }; |
148 |
final public DoubleBuffer asDoubleBuffer() { DoubleBuffer res = new MappedDoubleFileBuffer(ch); res.limit((limit()*1)/8); return res; } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position(), limit(), address); position(position() + 1); return a; } final public ByteBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), limit(), value, address); position(position() + 1); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index, limit(), address); return a; } final public ByteBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, limit(), value, address); return this; }; |
final public DoubleBuffer asDoubleBuffer() { DoubleBuffer res = new MappedDoubleFileBuffer(ch); res.limit((limit()*1)/8); return res; } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position(), limit(), map_address); position(position() + 1); return a; } final public ByteBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), limit(), value, map_address); position(position() + 1); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index, limit(), map_address); return a; } final public ByteBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, limit(), value, map_address); return this; }; |
149 |
} |
} |