/[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.3 by mark, Tue Apr 30 21:37:26 2002 UTC revision 1.4 by mkoch, Wed Nov 13 11:53:17 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 java.nio;  package java.nio;
39    
40  public abstract class ByteBuffer extends Buffer  public abstract class ByteBuffer extends Buffer
41  {  {
42      private ByteOrder endian = ByteOrder.BIG_ENDIAN;    private ByteOrder endian = ByteOrder.BIG_ENDIAN;
43     protected byte [] backing_buffer;    
44      public static ByteBuffer allocateDirect(int capacity)    protected byte [] backing_buffer;
45      {    
46          ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity);    public static ByteBuffer allocateDirect(int capacity)
47          return b;    {
48      }      ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity);
49      public static ByteBuffer allocate(int capacity)      return b;
50      {    }
51          ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity);    
52          return b;    public static ByteBuffer allocate(int capacity)
53      }    {
54     final public static ByteBuffer wrap(byte[] array,      ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity);
55                                int offset,      return b;
56                                int length)    }
57      {    
58          gnu.java.nio.ByteBufferImpl b = new gnu.java.nio. ByteBufferImpl(array, offset, length);    final public static ByteBuffer wrap(byte[] array, int offset, int length)
59          return b;    {
60      }      gnu.java.nio.ByteBufferImpl b = new gnu.java.nio. ByteBufferImpl(array, offset, length);
61        return b;
62      }
63      
64    final public static ByteBuffer wrap(String a)    final public static ByteBuffer wrap(String a)
65      {    {
66          return wrap(a.getBytes(), 0, a.length());      return wrap(a.getBytes(), 0, a.length());
67      }    }
68     final public static ByteBuffer wrap(byte[] array)    
69      {    final public static ByteBuffer wrap(byte[] array)
70          return wrap(array, 0, array.length);    {
71      }      return wrap(array, 0, array.length);
72      final public ByteBuffer get(byte[] dst,    }
73                              int offset,    
74                              int length)    final public ByteBuffer get(byte[] dst, int offset, int length)
75      {    {
76            for (int i = offset; i < offset + length; i++)      for (int i = offset; i < offset + length; i++)
77                {        {
78                    dst[i] = get();          dst[i] = get();
79                }        }
80            return this;      
81      }      return this;
82      }
83      
84    final public ByteBuffer get(byte[] dst)    final public ByteBuffer get(byte[] dst)
85      {    {
86          return get(dst, 0, dst.length);      return get(dst, 0, dst.length);
87      }    }
88      
89    final public ByteBuffer put(ByteBuffer src)    final public ByteBuffer put(ByteBuffer src)
90      {    {
91          while (src.hasRemaining())      while (src.hasRemaining())
92              put(src.get());        put(src.get());
93          return this;    
94      }      return this;
95    final public ByteBuffer put(byte[] src,    }
96                            int offset,    
97                            int length)    final public ByteBuffer put(byte[] src, int offset, int length)
98      {    {
99            for (int i = offset; i < offset + length; i++)      for (int i = offset; i < offset + length; i++)
100                put(src[i]);        put(src[i]);
101            return this;  
102      }      return this;
103  public final ByteBuffer put(byte[] src)    }
104      {  
105          return put(src, 0, src.length);    public final ByteBuffer put(byte[] src)
106      }    {
107  public final boolean hasArray()      return put(src, 0, src.length);
108      {    }
109        return (backing_buffer != null);  
110      }    public final boolean hasArray()
111  public final byte[] array()    {
112      {      return (backing_buffer != null);
113        return backing_buffer;    }
114      }  
115      public final int arrayOffset()    public final byte[] array()
116      {    {
117        return 0;      return backing_buffer;
118      }    }
119      public int hashCode()    
120      {    public final int arrayOffset()
121          return super.hashCode();    {
122      }      return 0;
123      public boolean equals(Object obj)    }
124      {    
125          if (obj instanceof ByteBuffer)    public int hashCode()
126              {    {
127                  return compareTo(obj) == 0;      return super.hashCode();
128              }    }
129          return false;    
130      }    public boolean equals(Object obj)
131      public int compareTo(Object ob)    {
132      {      if (obj instanceof ByteBuffer)
133          ByteBuffer a = (ByteBuffer) ob;        {
134          if (a.remaining() != remaining())          return compareTo(obj) == 0;
135              return 1;        }
136          if (! hasArray() ||    
137              ! a.hasArray())      return false;
138      }
139      
140      public int compareTo(Object ob)
141      {
142        ByteBuffer a = (ByteBuffer) ob;
143        if (a.remaining() != remaining())
144          return 1;
145        if (! hasArray() ||
146            ! a.hasArray())
147          {
148            return 1;
149          }
150        int r = remaining();
151        int i1 = pos;
152        int i2 = a.pos;
153        for (int i=0;i<r;i++)
154          {
155            int t = (int) (get(i1)- a.get(i2));
156            if (t != 0)
157            {            {
158              return 1;              return (int) t;
159            }            }
160          int r = remaining();        }
161          int i1 = pos;      return 0;
162          int i2 = a.pos;    }
163          for (int i=0;i<r;i++)    
164              {    public final ByteOrder order()
165                  int t = (int) (get(i1)- a.get(i2));    {
166                  if (t != 0)      return endian;
167                      {    }
168                          return (int) t;    
169                      }    public final ByteBuffer order(ByteOrder bo)
170              }    {
171          return 0;      endian = bo;
172      }      return this;
173      public final ByteOrder order()    }
174      {    
175          return endian;    public abstract byte get();
176      }    
177      public final ByteBuffer order(ByteOrder bo)    public abstract java.nio. ByteBuffer put(byte b);
178      {    
179          endian = bo;    public abstract byte get(int index);
180          return this;    
181      }    public abstract java.nio. ByteBuffer put(int index, byte b);
182      public abstract byte get();    
183      public abstract java.nio. ByteBuffer put(byte b);    public abstract ByteBuffer compact();
184      public abstract byte get(int index);    
185      public abstract java.nio. ByteBuffer put(int index, byte b);    public abstract boolean isDirect();
186      public abstract ByteBuffer compact();    
187      public abstract boolean isDirect();    public abstract ByteBuffer slice();
188      public abstract ByteBuffer slice();    
189      public abstract ByteBuffer duplicate();    public abstract ByteBuffer duplicate();
190      public abstract ByteBuffer asReadOnlyBuffer();    
191      public abstract ShortBuffer asShortBuffer();    public abstract ByteBuffer asReadOnlyBuffer();
192      public abstract CharBuffer asCharBuffer();    
193      public abstract IntBuffer asIntBuffer();    public abstract ShortBuffer asShortBuffer();
194      public abstract LongBuffer asLongBuffer();    
195      public abstract FloatBuffer asFloatBuffer();    public abstract CharBuffer asCharBuffer();
196      public abstract DoubleBuffer asDoubleBuffer();    
197      public abstract char getChar();    public abstract IntBuffer asIntBuffer();
198      public abstract ByteBuffer putChar(char value);    
199      public abstract char getChar(int index);    public abstract LongBuffer asLongBuffer();
200      public abstract ByteBuffer putChar(int index, char value);    
201      public abstract short getShort();    public abstract FloatBuffer asFloatBuffer();
202      public abstract ByteBuffer putShort(short value);    
203      public abstract short getShort(int index);    public abstract DoubleBuffer asDoubleBuffer();
204      public abstract ByteBuffer putShort(int index, short value);    
205      public abstract int getInt();    public abstract char getChar();
206      public abstract ByteBuffer putInt(int value);    
207      public abstract int getInt(int index);    public abstract ByteBuffer putChar(char value);
208      public abstract ByteBuffer putInt(int index, int value);    
209      public abstract long getLong();    public abstract char getChar(int index);
210      public abstract ByteBuffer putLong(long value);    
211      public abstract long getLong(int index);    public abstract ByteBuffer putChar(int index, char value);
212      public abstract ByteBuffer putLong(int index, long value);    
213      public abstract float getFloat();    public abstract short getShort();
214      public abstract ByteBuffer putFloat(float value);    
215      public abstract float getFloat(int index);    public abstract ByteBuffer putShort(short value);
216      public abstract ByteBuffer putFloat(int index, float value);    
217      public abstract double getDouble();    public abstract short getShort(int index);
218      public abstract ByteBuffer putDouble(double value);  
219      public abstract double getDouble(int index);    public abstract ByteBuffer putShort(int index, short value);
220      public abstract ByteBuffer putDouble(int index, double value);    
221      public abstract int getInt();
222      
223      public abstract ByteBuffer putInt(int value);
224      
225      public abstract int getInt(int index);
226      
227      public abstract ByteBuffer putInt(int index, int value);
228      
229      public abstract long getLong();
230      
231      public abstract ByteBuffer putLong(long value);
232      
233      public abstract long getLong(int index);
234      
235      public abstract ByteBuffer putLong(int index, long value);
236      
237      public abstract float getFloat();
238      
239      public abstract ByteBuffer putFloat(float value);
240      
241      public abstract float getFloat(int index);
242      
243      public abstract ByteBuffer putFloat(int index, float value);
244      
245      public abstract double getDouble();
246      
247      public abstract ByteBuffer putDouble(double value);
248      
249      public abstract double getDouble(int index);
250      
251      public abstract ByteBuffer putDouble(int index, double value);
252  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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