/[classpath]/classpath/java/nio/ByteBuffer.java
ViewVC logotype

Diff of /classpath/java/nio/ByteBuffer.java

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

revision 1.12 by mkoch, Sun May 18 12:12:40 2003 UTC revision 1.13 by mkoch, Mon May 19 08:36:27 2003 UTC
# Line 47  public abstract class ByteBuffer extends Line 47  public abstract class ByteBuffer extends
47  {  {
48    private ByteOrder endian = ByteOrder.BIG_ENDIAN;    private ByteOrder endian = ByteOrder.BIG_ENDIAN;
49    
50    protected int offset;    protected int array_offset;
51    protected byte[] backing_buffer;    protected byte[] backing_buffer;
52        
53    protected ByteBuffer (int capacity, int limit, int position, int mark)    protected ByteBuffer (int capacity, int limit, int position, int mark)
54    {    {
55      super (capacity, limit, position, mark);      super (capacity, limit, position, mark);
56        array_offset = 0;
57      }
58    
59      protected ByteBuffer (byte[] buffer, int offset, int capacity, int limit, int position, int mark)
60      {
61        super (capacity, limit, position, mark);
62        this.backing_buffer = buffer;
63        this.array_offset = offset;
64    }    }
65        
66    /**    /**
# Line 68  public abstract class ByteBuffer extends Line 76  public abstract class ByteBuffer extends
76     */     */
77    public static ByteBuffer allocate (int capacity)    public static ByteBuffer allocate (int capacity)
78    {    {
79      return new ByteBufferImpl (capacity, 0, capacity);      return new ByteBufferImpl (capacity);
80    }    }
81    
82    /**    /**
# Line 80  public abstract class ByteBuffer extends Line 88  public abstract class ByteBuffer extends
88     */     */
89    final public static ByteBuffer wrap (byte[] array, int offset, int length)    final public static ByteBuffer wrap (byte[] array, int offset, int length)
90    {    {
91      return new ByteBufferImpl (array, offset, length);      return new ByteBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
92    }    }
93    
94    /**    /**
# Line 91  public abstract class ByteBuffer extends Line 99  public abstract class ByteBuffer extends
99    {    {
100      return wrap (array, 0, array.length);      return wrap (array, 0, array.length);
101    }    }
102      
103    /**    /**
104     * This method transfers <code>bytes<code> from this buffer into the given     * This method transfers <code>bytes<code> from this buffer into the given
105     * destination array.     * destination array.
# Line 153  public abstract class ByteBuffer extends Line 161  public abstract class ByteBuffer extends
161      if (src == this)      if (src == this)
162        throw new IllegalArgumentException ();        throw new IllegalArgumentException ();
163    
164      while (src.hasRemaining ())      if (src.remaining () > remaining ())
165        put (src.get ());        throw new BufferOverflowException ();
166        
167        if (src.remaining () > 0)
168          {
169            byte[] toPut = new byte [src.remaining ()];
170            src.get (toPut);
171            src.put (toPut);
172          }
173    
174      return this;      return this;
175    }    }
176    
# Line 246  public abstract class ByteBuffer extends Line 261  public abstract class ByteBuffer extends
261    
262      if (isReadOnly ())      if (isReadOnly ())
263        throw new ReadOnlyBufferException ();        throw new ReadOnlyBufferException ();
264        
265      return offset;      return array_offset;
266    }    }
267    
268    /**    /**
# Line 283  public abstract class ByteBuffer extends Line 298  public abstract class ByteBuffer extends
298    {    {
299      ByteBuffer a = (ByteBuffer) obj;      ByteBuffer a = (ByteBuffer) obj;
300    
301      if (a.remaining() != remaining())      if (a.remaining () != remaining ())
302        {        return 1;
303          return 1;  
304        }      if (! hasArray () ||
305              ! a.hasArray ())
     if (! hasArray() ||  
         ! a.hasArray())  
306        {        {
307          return 1;          return 1;
308        }        }
# Line 590  public abstract class ByteBuffer extends Line 603  public abstract class ByteBuffer extends
603     * @exception BufferUnderflowException If there are fewer than eight bytes     * @exception BufferUnderflowException If there are fewer than eight bytes
604     * remaining in this buffer.     * remaining in this buffer.
605     */     */
606    public abstract double getDouble();    public abstract double getDouble ();
607        
608    /**    /**
609     * Relative put method for writing a double value.     * Relative put method for writing a double value.

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

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