jdk/src/share/classes/java/nio/StringCharBuffer.java
changeset 69 c7cd7bde95f3
parent 2 90ce3da70b43
child 715 f16baef3a20e
--- 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();
         }