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

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

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

revision 1.7 by mkoch, Wed Nov 13 09:19:39 2002 UTC revision 1.8 by mkoch, Sun Nov 17 12:21:36 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  public final class ByteBufferImpl extends java.nio. ByteBuffer  import java.nio.ByteBuffer;
41    
42    public final class ByteBufferImpl extends ByteBuffer
43  {  {
44    private byte[] backing_buffer;    private byte[] backing_buffer;
45      private int array_offset;    private int array_offset;
46      private boolean ro;    private boolean ro;
47    public ByteBufferImpl(int cap, int off, int lim)  
48      {    public ByteBufferImpl (int cap, int off, int lim)
49        this.backing_buffer = new byte[cap];    {
50        this.cap = cap;      this.cap = cap;
51        this.position(off);      position (off);
52        this.limit(lim);      limit (lim);
53      }      this.backing_buffer = new byte[cap];
54    public ByteBufferImpl(byte[] array, int off, int lim)    }
55      {  
56        this.backing_buffer = array;    public ByteBufferImpl (byte[] array, int off, int lim)
57        this.cap = array.length;    {
58        this.position(off);      this.cap = array.length;
59        this.limit(lim);      position (off);
60      }      limit (lim);
61    public ByteBufferImpl(ByteBufferImpl copy)      this.backing_buffer = array;
62      {    }
63          backing_buffer = copy.backing_buffer;  
64          ro = copy.ro;    public ByteBufferImpl (ByteBufferImpl copy)
65          position(copy.position());    {
66          limit(copy.limit());      this.cap = copy.capacity ();
67      }      position (copy.position ());
68      void inc_pos(int a)      limit (copy.limit ());
69      {      ro = copy.ro;
70        position(position() + a);      backing_buffer = copy.backing_buffer;
71      }    }
72    
73      void inc_pos (int toAdd)
74      {
75        position (position () + toAdd);
76      }
77    
78    private static native byte[] nio_cast(byte[]copy);    private static native byte[] nio_cast(byte[]copy);
79      
80    private static native byte[] nio_cast(char[]copy);    private static native byte[] nio_cast(char[]copy);
81      
82    private static native byte[] nio_cast(short[]copy);    private static native byte[] nio_cast(short[]copy);
83      
84    private static native byte[] nio_cast(long[]copy);    private static native byte[] nio_cast(long[]copy);
85      
86    private static native byte[] nio_cast(int[]copy);    private static native byte[] nio_cast(int[]copy);
87      
88    private static native byte[] nio_cast(float[]copy);    private static native byte[] nio_cast(float[]copy);
89      
90    private static native byte[] nio_cast(double[]copy);    private static native byte[] nio_cast(double[]copy);
91    ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ByteBufferImpl b, int index, int limit); private static native void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/1); return res; }    ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ByteBufferImpl b, int index, int limit); private static native void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/1); return res; }
92    ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ByteBufferImpl b, int index, int limit); private static native void nio_put_Char(ByteBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; }    ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ByteBufferImpl b, int index, int limit); private static native void nio_put_Char(ByteBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; }
# Line 110  public final class ByteBufferImpl extend Line 124  public final class ByteBufferImpl extend
124          return backing_buffer != null;          return backing_buffer != null;
125      }      }
126    final public byte get()    final public byte get()
127      {    {
128          byte e = backing_buffer[position()];      byte e = backing_buffer[position()];
129          position(position()+1);      position(position()+1);
130          return e;      return e;
131      }    }
132    final public java.nio. ByteBuffer put(byte b)    
133      {    final public ByteBuffer put(byte b)
134          backing_buffer[position()] = b;    {
135          position(position()+1);      backing_buffer[position()] = b;
136          return this;      position(position()+1);
137      }      return this;
138      }
139      
140    final public byte get(int index)    final public byte get(int index)
141      {      {
142          return backing_buffer[index];          return backing_buffer[index];

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