/[classpath]/classpath/gnu/java/nio/MappedByteFileBuffer.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/MappedByteFileBuffer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mkoch, Tue Mar 11 11:48:51 2003 UTC revision 1.8 by mkoch, Fri Mar 14 10:32:40 2003 UTC
# Line 36  obligated to do so.  If you do not wish Line 36  obligated to do so.  If you do not wish
36  exception statement from your version. */  exception statement from your version. */
37    
38  package gnu.java.nio;  package gnu.java.nio;
39  import java.nio.*;  
40  import java.io.IOException;  import java.io.IOException;
41    import java.nio.ByteBuffer;
42    import java.nio.CharBuffer;
43    import java.nio.DoubleBuffer;
44    import java.nio.FloatBuffer;
45    import java.nio.IntBuffer;
46    import java.nio.LongBuffer;
47    import java.nio.ShortBuffer;
48    import java.nio.MappedByteBuffer;
49    
50  final public class MappedByteFileBuffer  final public class MappedByteFileBuffer
51   extends MappedByteBuffer    extends MappedByteBuffer
52  {  {
53    public long address;    public long address;
54    boolean ro;    boolean readOnly;
55    boolean direct;    boolean direct;
56    public FileChannelImpl ch;    public FileChannelImpl ch;
57      
58    public MappedByteFileBuffer(FileChannelImpl ch)    public MappedByteFileBuffer(FileChannelImpl ch)
59    {    {
60      // FIXME      // FIXME
# Line 52  final public class MappedByteFileBuffer Line 62  final public class MappedByteFileBuffer
62      this.ch = ch;      this.ch = ch;
63      address = ch.address;      address = ch.address;
64    }    }
65      
66    public MappedByteFileBuffer(MappedByteFileBuffer b)    public MappedByteFileBuffer(MappedByteFileBuffer b)
67    {    {
68      // FIXME      // FIXME
69      super (0, 0, 0, 0);      super (0, 0, 0, 0);
70      this.ro = b.ro;      this.readOnly = b.readOnly;
71      this.ch = b.ch;      this.ch = b.ch;
72      address = b.address;      address = b.address;
73    }    }
74    public boolean isReadOnly()    
75      public boolean isReadOnly ()
76    {    {
77      return ro;      return readOnly;
78    }    }
79    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, long address); public static native void nio_write_Byte_file_channel(FileChannelImpl ch, int index, int limit, byte value, long address);
80    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, long address); public static native void nio_write_Short_file_channel(FileChannelImpl ch, int index, int limit, short value, long address);
# Line 71  final public class MappedByteFileBuffer Line 83  final public class MappedByteFileBuffer
83    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, long address); public static native void nio_write_Long_file_channel(FileChannelImpl ch, int index, int limit, long value, long address);
84    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, long address); public static native void nio_write_Float_file_channel(FileChannelImpl ch, int index, int limit, float value, long address);
85    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, long address); public static native void nio_write_Double_file_channel(FileChannelImpl ch, int index, int limit, double value, long address);
86  final public byte get()  
87      final public byte get()
88    {    {
89      byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address);      byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address);
90      position(position() + 1);      position(position() + 1);
91      return a;      return a;
92    }    }
93  final public ByteBuffer put(byte b)  
94      final public ByteBuffer put(byte b)
95    {    {
96      MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), b, address);      MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), b, address);
97      position(position() + 1);      position(position() + 1);
98      return this;      return this;
99    }    }
100  final public byte get(int index)  
101      final public byte get(int index)
102    {    {
103      byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address);      byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address);
104      return a;      return a;
105    }    }
106  final public ByteBuffer put(int index, byte b)  
107      final public ByteBuffer put(int index, byte b)
108    {    {
109      MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), b, address);      MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), b, address);
110      return this;      return this;
111    }    }
112  final public ByteBuffer compact()  
113      final public ByteBuffer compact()
114    {    {
115      return this;      return this;
116    }    }
117  final public boolean isDirect()  
118      final public boolean isDirect()
119    {    {
120      return direct;      return direct;
121    }    }
122  final public ByteBuffer slice()  
123      final public ByteBuffer slice()
124    {    {
125      MappedByteFileBuffer A = new MappedByteFileBuffer(this);      MappedByteFileBuffer A = new MappedByteFileBuffer(this);
126      return A;      return A;
127    }    }
128  public ByteBuffer duplicate()  
129      public ByteBuffer duplicate()
130    {    {
131      return new MappedByteFileBuffer(this);      return new MappedByteFileBuffer(this);
132    }    }
133  public ByteBuffer asReadOnlyBuffer()  
134      public ByteBuffer asReadOnlyBuffer()
135    {    {
136      MappedByteFileBuffer b = new MappedByteFileBuffer(this);      MappedByteFileBuffer b = new MappedByteFileBuffer(this);
137      b.ro = true;      b.readOnly = true;
138      return b;      return b;
139    }    }
140    
141    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(), 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; };
142    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(), 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; };
143    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(), 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; };

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26