--- a/jdk/src/share/classes/java/nio/StringCharBuffer.java Thu Mar 13 19:29:41 2008 +0000
+++ b/jdk/src/share/classes/java/nio/StringCharBuffer.java Thu Mar 13 19:34:49 2008 +0000
@@ -60,16 +60,9 @@
str = s;
}
- private StringCharBuffer(CharSequence s, int mark,
- int pos, int limit, int cap)
- {
- super(mark, pos, limit, cap);
- str = s;
- }
-
public CharBuffer duplicate() {
return new StringCharBuffer(str, markValue(),
- position(), limit(), capacity());
+ position(), limit(), capacity(), offset);
}
public CharBuffer asReadOnlyBuffer() {
@@ -77,11 +70,11 @@
}
public final char get() {
- return str.charAt(nextGetIndex());
+ return str.charAt(nextGetIndex() + offset);
}
public final char get(int index) {
- return str.charAt(checkIndex(index));
+ return str.charAt(checkIndex(index) + offset);
}
// ## Override bulk get methods for better performance
@@ -103,15 +96,16 @@
}
final String toString(int start, int end) {
- return str.toString().substring(start, end);
+ return str.toString().substring(start + offset, end + offset);
}
public final CharSequence subSequence(int start, int end) {
try {
int pos = position();
- return new StringCharBuffer(str,
+ return new StringCharBuffer(str, -1,
pos + checkIndex(start, pos),
- pos + checkIndex(end, pos));
+ pos + checkIndex(end, pos),
+ remaining(), offset);
} catch (IllegalArgumentException x) {
throw new IndexOutOfBoundsException();
}