2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
40 public abstract class Buffer
43 private int limit
= 0;
45 private int mark
= -1;
47 // Creates a new Buffer.
49 // Should be package private.
51 Buffer (int capacity
, int limit
, int position
, int mark
)
54 throw new IllegalArgumentException ();
63 throw new IllegalArgumentException ();
70 * Retrieves the capacity of the buffer.
72 public final int capacity ()
80 public final Buffer
clear ()
91 public final Buffer
flip ()
100 * Tells whether the buffer has remaining data to read or not.
102 public final boolean hasRemaining ()
108 * Tells whether this buffer is read only or not.
110 public abstract boolean isReadOnly ();
113 * Retrieves the current limit of the buffer.
115 public final int limit ()
121 * Sets this buffer's limit.
123 * @param newLimit The new limit value; must be non-negative and no larger
124 * than this buffer's capacity.
126 * @exception IllegalArgumentException If the preconditions on newLimit
129 public final Buffer
limit (int newLimit
)
131 if ((newLimit
< 0) || (newLimit
> cap
))
132 throw new IllegalArgumentException ();
134 if (newLimit
<= mark
)
145 * Sets this buffer's mark at its position.
147 public final Buffer
mark ()
154 * Retrieves the current position of this buffer.
156 public final int position ()
162 * Sets this buffer's position. If the mark is defined and larger than the
163 * new position then it is discarded.
165 * @param newPosition The new position value; must be non-negative and no
166 * larger than the current limit.
168 * @exception IllegalArgumentException If the preconditions on newPosition
171 public final Buffer
position (int newPosition
)
173 if ((newPosition
< 0) || (newPosition
> limit
))
174 throw new IllegalArgumentException ();
176 if (newPosition
<= mark
)
184 * Returns the number of elements between the current position and the limit.
186 public final int remaining()
192 * Resets this buffer's position to the previously-marked position.
194 * @exception InvalidMarkException If the mark has not been set.
196 public final Buffer
reset()
199 throw new InvalidMarkException ();
206 * Rewinds this buffer. The position is set to zero and the mark
209 public final Buffer
rewind()