diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/nio/CharBuffer.java | |
parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
download | gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/nio/CharBuffer.java')
-rw-r--r-- | libjava/classpath/java/nio/CharBuffer.java | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/libjava/classpath/java/nio/CharBuffer.java b/libjava/classpath/java/nio/CharBuffer.java index 356a920eea0..34f429f62f7 100644 --- a/libjava/classpath/java/nio/CharBuffer.java +++ b/libjava/classpath/java/nio/CharBuffer.java @@ -1,5 +1,5 @@ /* CharBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,11 +38,13 @@ exception statement from your version. */ package java.nio; +import java.io.IOException; + /** * @since 1.4 */ public abstract class CharBuffer extends Buffer - implements Comparable, CharSequence + implements Comparable<CharBuffer>, CharSequence, Readable, Appendable { int array_offset; char[] backing_buffer; @@ -163,6 +165,18 @@ public abstract class CharBuffer extends Buffer return this; } + /** @since 1.5 */ + public int read(CharBuffer buffer) throws IOException + { + // We want to call put(), so we don't manipulate the CharBuffer + // directly. + int rem = Math.min(buffer.remaining(), remaining()); + char[] buf = new char[rem]; + get(buf); + buffer.put(buf); + return rem; + } + /** * This method transfers <code>char</code>s from this buffer into the given * destination array. @@ -323,7 +337,7 @@ public abstract class CharBuffer extends Buffer { if (obj instanceof CharBuffer) { - return compareTo (obj) == 0; + return compareTo ((CharBuffer) obj) == 0; } return false; @@ -335,10 +349,8 @@ public abstract class CharBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>CharBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (CharBuffer other) { - CharBuffer other = (CharBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); @@ -503,4 +515,25 @@ public abstract class CharBuffer extends Buffer return get (position () + index); } + + /** @since 1.5 */ + public CharBuffer append(char c) + { + put(c); + return this; + } + + /** @since 1.5 */ + public CharBuffer append(CharSequence cs) + { + put(cs == null ? "null" : cs.toString()); + return this; + } + + /** @since 1.5 */ + public CharBuffer append(CharSequence cs, int start, int end) + { + put(cs == null ? "null" : cs.subSequence(start, end).toString()); + return this; + } } |