mirror of git://gcc.gnu.org/git/gcc.git
2004-05-30 Michael Koch <konqueror@gmx.de>
* java/nio/Buffer.java (limit): Fixed off by one error. * java/nio/CharBuffer.java (wrap): Fixed arguments, added javadocs. From-SVN: r82448
This commit is contained in:
parent
74c2dbf7a1
commit
1b2545bcf2
|
|
@ -1,3 +1,10 @@
|
||||||
|
2004-05-30 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/nio/Buffer.java
|
||||||
|
(limit): Fixed off by one error.
|
||||||
|
* java/nio/CharBuffer.java
|
||||||
|
(wrap): Fixed arguments, added javadocs.
|
||||||
|
|
||||||
2004-05-30 Michael Koch <konqueror@gmx.de>
|
2004-05-30 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* gnu/java/beans/BeanInfoEmbryo.java,
|
* gnu/java/beans/BeanInfoEmbryo.java,
|
||||||
|
|
|
||||||
|
|
@ -148,11 +148,11 @@ public abstract class Buffer
|
||||||
if ((newLimit < 0) || (newLimit > cap))
|
if ((newLimit < 0) || (newLimit > cap))
|
||||||
throw new IllegalArgumentException ();
|
throw new IllegalArgumentException ();
|
||||||
|
|
||||||
if (newLimit <= mark)
|
if (newLimit < mark)
|
||||||
mark = -1;
|
mark = -1;
|
||||||
|
|
||||||
if (pos > newLimit)
|
if (pos > newLimit)
|
||||||
pos = newLimit - 1;
|
pos = newLimit;
|
||||||
|
|
||||||
limit = newLimit;
|
limit = newLimit;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -65,56 +65,75 @@ public abstract class CharBuffer extends Buffer
|
||||||
* Wraps a <code>char</code> array into a <code>CharBuffer</code>
|
* Wraps a <code>char</code> array into a <code>CharBuffer</code>
|
||||||
* object.
|
* object.
|
||||||
*
|
*
|
||||||
|
* @param array the array to wrap
|
||||||
|
* @param offset the offset of the region in the array to wrap
|
||||||
|
* @param length the length of the region in the array to wrap
|
||||||
|
*
|
||||||
|
* @return a new <code>CharBuffer</code> object
|
||||||
|
*
|
||||||
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
||||||
* and length parameters do not hold
|
* and length parameters do not hold
|
||||||
*/
|
*/
|
||||||
final public static CharBuffer wrap (char[] array, int offset, int length)
|
final public static CharBuffer wrap(char[] array, int offset, int length)
|
||||||
{
|
{
|
||||||
return new CharBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
|
return new CharBufferImpl(array, 0, array.length, offset + length, offset, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a character sequence into a <code>CharBuffer</code> object.
|
* Wraps a character sequence into a <code>CharBuffer</code> object.
|
||||||
|
*
|
||||||
|
* @param seq the sequence to wrap
|
||||||
|
*
|
||||||
|
* @return a new <code>CharBuffer</code> object
|
||||||
*/
|
*/
|
||||||
final public static CharBuffer wrap (CharSequence a)
|
final public static CharBuffer wrap(CharSequence seq)
|
||||||
{
|
{
|
||||||
return wrap (a, 0, a.length ());
|
return wrap(seq, 0, seq.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a character sequence into a <code>CharBuffer</code> object.
|
* Wraps a character sequence into a <code>CharBuffer</code> object.
|
||||||
*
|
*
|
||||||
|
* @param seq the sequence to wrap
|
||||||
|
* @param start the index of the first character to wrap
|
||||||
|
* @param end the index of the first character not to wrap
|
||||||
|
*
|
||||||
|
* @return a new <code>CharBuffer</code> object
|
||||||
|
*
|
||||||
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
||||||
* and length parameters do not hold
|
* and length parameters do not hold
|
||||||
*/
|
*/
|
||||||
final public static CharBuffer wrap (CharSequence a, int offset, int length)
|
final public static CharBuffer wrap(CharSequence seq, int start, int end)
|
||||||
{
|
{
|
||||||
// FIXME: implement better handling of java.lang.String.
|
// FIXME: implement better handling of java.lang.String.
|
||||||
// Probably share data with String via reflection.
|
// Probably share data with String via reflection.
|
||||||
|
|
||||||
if ((offset < 0)
|
if ((start < 0)
|
||||||
|| (offset > a.length ())
|
|| (start > seq.length())
|
||||||
|| (length < 0)
|
|| (end < start)
|
||||||
|| (length > (a.length () - offset)))
|
|| (end > (seq.length() - start)))
|
||||||
throw new IndexOutOfBoundsException ();
|
throw new IndexOutOfBoundsException();
|
||||||
|
|
||||||
char [] buffer = new char [a.length ()];
|
int len = end - start;
|
||||||
|
char[] buffer = new char[len];
|
||||||
|
|
||||||
for (int i = offset; i < length; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
buffer[i] = seq.charAt(i + start);
|
||||||
buffer [i] = a.charAt (i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return wrap (buffer, offset, length).asReadOnlyBuffer ();
|
return wrap(buffer, 0, len).asReadOnlyBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a <code>char</code> array into a <code>CharBuffer</code>
|
* Wraps a <code>char</code> array into a <code>CharBuffer</code>
|
||||||
* object.
|
* object.
|
||||||
|
*
|
||||||
|
* @param array the array to wrap
|
||||||
|
*
|
||||||
|
* @return a new <code>CharBuffer</code> object
|
||||||
*/
|
*/
|
||||||
final public static CharBuffer wrap (char[] array)
|
final public static CharBuffer wrap(char[] array)
|
||||||
{
|
{
|
||||||
return wrap (array, 0, array.length);
|
return wrap(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue