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

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

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

revision 1.6 by mark, Tue Apr 30 21:37:26 2002 UTC revision 1.7 by mkoch, Fri Nov 22 13:06:50 2002 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    
49  final public class MappedCharFileBuffer  final public class MappedCharFileBuffer
50   extends CharBuffer    extends CharBuffer
51  {  {
52    public long address;    public long address;
53    boolean ro;    boolean ro;
54    boolean direct;    boolean direct;
55    public FileChannelImpl ch;    public FileChannelImpl ch;
56    
57    public MappedCharFileBuffer(FileChannelImpl ch)    public MappedCharFileBuffer(FileChannelImpl ch)
58    {    {
59      this.ch = ch;      this.ch = ch;
# Line 56  final public class MappedCharFileBuffer Line 65  final public class MappedCharFileBuffer
65        System.err.println("failed to get size of file-channel's file");        System.err.println("failed to get size of file-channel's file");
66      }      }
67    }    }
68    
69    public MappedCharFileBuffer(MappedCharFileBuffer b)    public MappedCharFileBuffer(MappedCharFileBuffer b)
70    {    {
71      this.ro = b.ro;      this.ro = b.ro;
# Line 63  final public class MappedCharFileBuffer Line 73  final public class MappedCharFileBuffer
73      address = b.address;      address = b.address;
74      limit(b.limit());      limit(b.limit());
75    }    }
76    
77    public boolean isReadOnly()    public boolean isReadOnly()
78    {    {
79      return ro;      return ro;
80    }    }
81  final public char get()    
82      final public char get()
83    {    {
84      char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), address);      char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), address);
85      position(position() + 2);      position(position() + 2);
86      return a;      return a;
87    }    }
88  final public CharBuffer put(char b)  
89      final public CharBuffer put(char b)
90    {    {
91      MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), b, address);      MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), b, address);
92      position(position() + 2);      position(position() + 2);
93      return this;      return this;
94    }    }
95  final public char get(int index)  
96      final public char get(int index)
97    {    {
98      char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), address);      char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), address);
99      return a;      return a;
100    }    }
101  final public CharBuffer put(int index, char b)  
102      final public CharBuffer put(int index, char b)
103    {    {
104      MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, limit(), b, address);      MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, limit(), b, address);
105      return this;      return this;
106    }    }
107  final public CharBuffer compact()  
108      final public CharBuffer compact()
109    {    {
110      return this;      return this;
111    }    }
112  final public boolean isDirect()  
113      final public boolean isDirect()
114    {    {
115      return direct;      return direct;
116    }    }
117  final public CharBuffer slice()  
118      final public CharSequence subSequence (int start, int end)
119      {
120        // FIXME
121        return null;
122      }
123    
124      final public CharBuffer slice()
125    {    {
126      MappedCharFileBuffer A = new MappedCharFileBuffer(this);      MappedCharFileBuffer A = new MappedCharFileBuffer(this);
127      return A;      return A;
128    }    }
129  public CharBuffer duplicate()  
130      public CharBuffer duplicate()
131    {    {
132      return new MappedCharFileBuffer(this);      return new MappedCharFileBuffer(this);
133    }    }
134  public CharBuffer asReadOnlyBuffer()  
135      public CharBuffer asReadOnlyBuffer()
136    {    {
137      MappedCharFileBuffer b = new MappedCharFileBuffer(this);      MappedCharFileBuffer b = new MappedCharFileBuffer(this);
138      b.ro = true;      b.ro = true;
139      return b;      return b;
140    }    }
141    
142    final public ByteBuffer asByteBuffer() { ByteBuffer res = new MappedByteFileBuffer(ch); res.limit((limit()*2)/1); return res; } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address); return a; } final public CharBuffer 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()*2)/1); return res; } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index, limit(), address); return a; } final public CharBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, limit(), value, address); return this; };
143    final public CharBuffer asCharBuffer() { CharBuffer res = new MappedCharFileBuffer(ch); res.limit((limit()*2)/2); return res; } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), address); return a; } final public CharBuffer 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()*2)/2); return res; } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index, limit(), address); return a; } final public CharBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, limit(), value, address); return this; };
144    final public ShortBuffer asShortBuffer() { ShortBuffer res = new MappedShortFileBuffer(ch); res.limit((limit()*2)/2); return res; } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index, limit(), address); return a; } final public CharBuffer 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()*2)/2); return res; } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position(), limit(), address); position(position() + 2); return a; } final public CharBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), limit(), value, address); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index, limit(), address); return a; } final public CharBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, limit(), value, address); return this; };

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

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