diff --git a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java index bc2d82e648..a67c48c415 100644 --- a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java @@ -19,15 +19,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; import java.util.NoSuchElementException; -import org.jboss.netty.util.CharsetUtil; - /** * A skeletal implementation of a buffer. @@ -175,44 +171,6 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { dst.writerIndex(dst.writerIndex() + length); } - public String getString(int index, int length, Charset charset) { - if (length == 0) { - return ""; - } - - final CharsetDecoder decoder = CharsetUtil.getDecoder(charset); - final CharBuffer dst = CharBuffer.allocate( - (int) ((double) length * decoder.maxCharsPerByte())); - - int decodedChars = getString(index, length, dst, charset); - if (decodedChars == 0) { - return ""; - } - return dst.flip().toString(); - } - - public int getString(int index, int length, char[] dst, Charset charset) { - return getString(index, length, CharBuffer.wrap(dst), charset); - } - - public int getString( - int index, int length, - char[] dst, int dstOffset, int dstLength, Charset charset) { - return getString(index, length, CharBuffer.wrap( - dst, dstOffset, dstLength), charset); - } - - public int getString(int index, int length, Appendable out, Charset charset) - throws IOException { - if (out instanceof CharBuffer) { - return getString(index, length, out, charset); - } - - String str = getString(index, length, charset); - out.append(str); - return str.length(); - } - public void setChar(int index, char value) { setShort(index, (short) value); } @@ -422,35 +380,6 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { readerIndex += length; } - public int readString(int length, char[] dst, Charset charset) { - checkReadableBytes(length); - int result = getString(readerIndex, length, dst, charset); - readerIndex += length; - return result; - } - - public int readString(int length, char[] dst, int dstOffset, int dstLength, Charset charset) { - checkReadableBytes(length); - int result = getString(readerIndex, length, dst, dstOffset, dstLength, charset); - readerIndex += length; - return result; - } - - public int readString(int length, Appendable out, Charset charset) - throws IOException { - checkReadableBytes(length); - int result = getString(readerIndex, length, out, charset); - readerIndex += length; - return result; - } - - public String readString(int length, Charset charset) { - checkReadableBytes(length); - String result = getString(readerIndex, length, charset); - readerIndex += length; - return result; - } - public void skipBytes(int length) { int newReaderIndex = readerIndex + length; if (newReaderIndex > writerIndex) { @@ -603,9 +532,10 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { } public String toString(Charset charset) { - return getString(readerIndex, readableBytes(), charset); + return toString(readerIndex, readableBytes(), charset); } + @Deprecated public String toString(int index, int length, String charsetName, ChannelBufferIndexFinder terminatorFinder) { if (terminatorFinder == null) { @@ -620,15 +550,18 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { return toString(index, terminatorIndex - index, charsetName); } + @Deprecated public String toString(int index, int length, String charsetName) { - return getString(index, length, Charset.forName(charsetName)); + return toString(index, length, Charset.forName(charsetName)); } + @Deprecated public String toString(String charsetName, ChannelBufferIndexFinder terminatorFinder) { return toString(readerIndex, readableBytes(), charsetName, terminatorFinder); } + @Deprecated public String toString(String charsetName) { return toString(Charset.forName(charsetName)); } diff --git a/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java index 710160dff0..ea0937733c 100644 --- a/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java @@ -20,14 +20,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; - -import org.jboss.netty.util.CharsetUtil; /** * A NIO {@link ByteBuffer} based buffer. It is recommended to use {@link ChannelBuffers#directBuffer(int)} @@ -303,18 +299,14 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer { } } - public int getString(int index, int length, CharBuffer dst, Charset charset) { + public String toString(int index, int length, Charset charset) { if (length == 0) { - return 0; + return ""; } - final CharsetDecoder decoder = CharsetUtil.getDecoder(charset); - final int start = dst.position(); - final ByteBuffer src = - ((ByteBuffer) buffer.duplicate().position( - index).limit(index + length)).order(order()); - ChannelBuffers.decodeString(src, dst, decoder); - return dst.position() - start; + return ChannelBuffers.decodeString( + ((ByteBuffer) buffer.duplicate().position(index).limit(index + length)), + charset); } public ChannelBuffer slice(int index, int length) { diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java index 8baa5d99e3..197dfe9724 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -708,22 +707,6 @@ public interface ChannelBuffer extends Comparable { */ int getBytes(int index, GatheringByteChannel out, int length) throws IOException; - // FIXME Document me - int getString(int index, int length, char[] dst, Charset charset); - // FIXME Document me - int getString(int index, int length, char[] dst, int dstOffset, int dstLength, Charset charset); - // FIXME Document me - int getString(int index, int length, Appendable out, Charset charset) throws IOException; - // FIXME Document me - int getString(int index, int length, CharBuffer dst, Charset charset); - - /** - * Decodes this buffer's sub-region into a string with the specified - * character set. This method does not modify {@code readerIndex} or - * {@code writerIndex} of this buffer. - */ - String getString(int index, int length, Charset charset); - /** * Sets the specified byte at the specified absolute {@code index} in this * buffer. @@ -1253,15 +1236,6 @@ public interface ChannelBuffer extends Comparable { */ int readBytes(GatheringByteChannel out, int length) throws IOException; - // FIXME Document me - int readString(int length, char[] dst, Charset charset); - // FIXME Document me - int readString(int length, char[] dst, int dstOffset, int dstLength, Charset charset); - // FIXME Document me - int readString(int length, Appendable out, Charset charset) throws IOException ; - // FIXME Document me - String readString(int length, Charset charset); - /** * Increases the current {@code readerIndex} by the specified * {@code length} in this buffer. @@ -1648,6 +1622,13 @@ public interface ChannelBuffer extends Comparable { */ String toString(Charset charset); + /** + * Decodes this buffer's sub-region into a string with the specified + * character set. This method does not modify {@code readerIndex} or + * {@code writerIndex} of this buffer. + */ + String toString(int index, int length, Charset charset); + /** * @deprecated Use {@link #toString(Charset)} instead. */ @@ -1655,20 +1636,20 @@ public interface ChannelBuffer extends Comparable { String toString(String charsetName); /** - * @deprecated Use {@link #getString(int, int, Charset)} instead. + * @deprecated Use {@link #toString(int, int, Charset)} instead. */ @Deprecated String toString( String charsetName, ChannelBufferIndexFinder terminatorFinder); /** - * @deprecated Use {@link #getString(int, int, Charset)} instead. + * @deprecated Use {@link #toString(int, int, Charset)} instead. */ @Deprecated String toString(int index, int length, String charsetName); /** - * @deprecated Use {@link #getString(int, int, Charset)} instead. + * @deprecated Use {@link #toString(int, int, Charset)} instead. */ @Deprecated String toString( diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java b/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java index 9218ebdfa4..bd4c0f9644 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java @@ -792,12 +792,9 @@ public class ChannelBuffers { } private static ChannelBuffer copiedBuffer(ByteOrder endianness, CharBuffer buffer, Charset charset) { - CharsetEncoder encoder = CharsetUtil.getEncoder(charset); CharBuffer src = buffer; - ByteBuffer dst = ByteBuffer.allocate( - (int) ((double) buffer.remaining() * encoder.maxBytesPerChar())); - ChannelBuffers.encodeString(src, dst, encoder); - ChannelBuffer result = wrappedBuffer(endianness, dst.array()); + ByteBuffer dst = ChannelBuffers.encodeString(src, charset); + ChannelBuffer result = wrappedBuffer(endianness, dst.array(), 0, dst.remaining()); result.writerIndex(dst.position()); return result; } @@ -1114,7 +1111,10 @@ public class ChannelBuffers { return -1; } - static void encodeString(CharBuffer src, ByteBuffer dst, CharsetEncoder encoder) { + static ByteBuffer encodeString(CharBuffer src, Charset charset) { + final CharsetEncoder encoder = CharsetUtil.getEncoder(charset); + final ByteBuffer dst = ByteBuffer.allocate( + (int) ((double) src.remaining() * encoder.maxBytesPerChar())); try { CoderResult cr = encoder.encode(src, dst, true); if (!cr.isUnderflow()) { @@ -1127,9 +1127,14 @@ public class ChannelBuffers { } catch (CharacterCodingException x) { throw new IllegalStateException(x); } + dst.flip(); + return dst; } - static void decodeString(ByteBuffer src, CharBuffer dst, CharsetDecoder decoder) { + static String decodeString(ByteBuffer src, Charset charset) { + final CharsetDecoder decoder = CharsetUtil.getDecoder(charset); + final CharBuffer dst = CharBuffer.allocate( + (int) ((double) src.remaining() * decoder.maxCharsPerByte())); try { CoderResult cr = decoder.decode(src, dst, true); if (!cr.isUnderflow()) { @@ -1142,6 +1147,7 @@ public class ChannelBuffers { } catch (CharacterCodingException x) { throw new IllegalStateException(x); } + return dst.flip().toString(); } private ChannelBuffers() { diff --git a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java index 5ab671e1e9..bda57bdc78 100644 --- a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java @@ -20,17 +20,13 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.jboss.netty.util.CharsetUtil; - /** * A virtual buffer which shows multiple buffers as a single merged buffer. It @@ -590,15 +586,15 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { return buffers.toArray(new ByteBuffer[buffers.size()]); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { - int componentId = componentId(index); - if (index + length <= indices[componentId + 1]) { - return components[componentId].getString( - index - indices[componentId], length, dst, charset); + public String toString(int index, int length, Charset charset) { + if (length == 0) { + return ""; } - if (length == 0) { - return 0; + int componentId = componentId(index); + if (index + length <= indices[componentId + 1]) { + return components[componentId].toString( + index - indices[componentId], length, charset); } byte[] data = new byte[length]; @@ -617,11 +613,8 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { i ++; } - final CharsetDecoder decoder = CharsetUtil.getDecoder(charset); - final int start = dst.position(); - final ByteBuffer src = ByteBuffer.wrap(data); - ChannelBuffers.decodeString(src, dst, decoder); - return dst.position() - start; + return ChannelBuffers.decodeString( + ByteBuffer.wrap(data), charset); } private int componentId(int index) { diff --git a/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java index 074806eade..183370be8e 100644 --- a/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -182,7 +181,7 @@ public class DuplicatedChannelBuffer extends AbstractChannelBuffer implements Wr return buffer.toByteBuffer(index, length); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { - return buffer.getString(index, length, dst, charset); + public String toString(int index, int length, Charset charset) { + return buffer.toString(index, length, charset); } } diff --git a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java index 9e3dcaab99..6a1dfee3c5 100644 --- a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -292,7 +291,7 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer { return buffer.toByteBuffer(index, length); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { - return buffer.getString(index, length, dst, charset); + public String toString(int index, int length, Charset charset) { + return buffer.toString(index, length, charset); } } diff --git a/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java index 9935f09048..e6e12d1171 100644 --- a/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java @@ -19,14 +19,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.nio.CharBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; - -import org.jboss.netty.util.CharsetUtil; /** * A skeletal implementation for Java heap buffers. @@ -122,16 +118,13 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer { return out.write(ByteBuffer.wrap(array, index, length)); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { + public String toString(int index, int length, Charset charset) { if (length == 0) { - return 0; + return ""; } - final CharsetDecoder decoder = CharsetUtil.getDecoder(charset); - final int start = dst.position(); - final ByteBuffer src = ByteBuffer.wrap(array, index, length); - ChannelBuffers.decodeString(src, dst, decoder); - return dst.position() - start; + return ChannelBuffers.decodeString( + ByteBuffer.wrap(array, index, length), charset); } public void setByte(int index, byte value) { diff --git a/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java index 34d6ade4de..c948a9efdb 100644 --- a/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.ReadOnlyBufferException; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; @@ -196,7 +195,7 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap return buffer.capacity(); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { - return buffer.getString(index, length, dst, charset); + public String toString(int index, int length, Charset charset) { + return buffer.toString(index, length, charset); } } diff --git a/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java index df84d45f67..ea0a7ca3dd 100644 --- a/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -215,9 +214,9 @@ public class SlicedChannelBuffer extends AbstractChannelBuffer implements Wrappe return buffer.toByteBuffer(index + adjustment, length); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { + public String toString(int index, int length, Charset charset) { checkIndex(index, length); - return buffer.getString(index + adjustment, length, dst, charset); + return buffer.toString(index + adjustment, length, charset); } private void checkIndex(int index) { diff --git a/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java index 9cab9025d4..59e1aa5542 100644 --- a/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -209,9 +208,9 @@ public class TruncatedChannelBuffer extends AbstractChannelBuffer implements Wra return buffer.toByteBuffer(index, length); } - public int getString(int index, int length, CharBuffer dst, Charset charset) { + public String toString(int index, int length, Charset charset) { checkIndex(index, length); - return buffer.getString(index, length, dst, charset); + return buffer.toString(index, length, charset); } private void checkIndex(int index) { diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java index f1724a93bf..8abe2a242f 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java @@ -20,7 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; @@ -325,28 +324,6 @@ class ReplayingDecoderBuffer implements ChannelBuffer { throw new UnreplayableOperationException(); } - public int readString(int length, Appendable out, Charset charset) - throws IOException { - checkReadableBytes(length); - return buffer.readString(length, out, charset); - } - - public int readString(int length, char[] dst, Charset charset) { - checkReadableBytes(length); - return buffer.readString(length, dst, charset); - } - - public int readString(int length, char[] dst, int dstOffset, int dstLength, Charset charset) { - checkReadableBytes(length); - return buffer.readString(length, dst, dstOffset, dstLength, charset); - } - - public String readString(int length, Charset charset) { - checkReadableBytes(length); - // TODO Auto-generated method stub - return null; - } - public int readerIndex() { return buffer.readerIndex(); } @@ -528,31 +505,9 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return buffer.toByteBuffers(index, length); } - public String getString(int index, int length, Charset charset) { + public String toString(int index, int length, Charset charset) { checkIndex(index, length); - return buffer.getString(index, length, charset); - } - - public int getString(int index, int length, Appendable out, Charset charset) - throws IOException { - checkIndex(index, length); - return buffer.getString(index, length, out, charset); - } - - public int getString(int index, int length, char[] dst, Charset charset) { - checkIndex(index, length); - return buffer.getString(index, length, dst, charset); - } - - public int getString(int index, int length, char[] dst, int dstOffset, int dstLength, - Charset charset) { - checkIndex(index, length); - return buffer.getString(index, length, dst, dstOffset, dstLength, charset); - } - - public int getString(int index, int length, CharBuffer dst, Charset charset) { - checkIndex(index, length); - return buffer.getString(index, length, dst, charset); + return buffer.toString(index, length, charset); } public String toString(Charset charsetName) { diff --git a/src/test/java/org/jboss/netty/buffer/ReadOnlyChannelBufferTest.java b/src/test/java/org/jboss/netty/buffer/ReadOnlyChannelBufferTest.java index 6839e9b047..4df231fd90 100644 --- a/src/test/java/org/jboss/netty/buffer/ReadOnlyChannelBufferTest.java +++ b/src/test/java/org/jboss/netty/buffer/ReadOnlyChannelBufferTest.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.nio.CharBuffer; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; @@ -96,11 +95,10 @@ public class ReadOnlyChannelBufferTest { ByteBuffer bb = ByteBuffer.allocate(100); ByteBuffer[] bbs = new ByteBuffer[] { ByteBuffer.allocate(101), ByteBuffer.allocate(102) }; - CharBuffer cb = CharBuffer.allocate(100); expect(buf.toByteBuffer(23, 24)).andReturn(bb); expect(buf.toByteBuffers(25, 26)).andReturn(bbs); - expect(buf.getString(27, 28, cb, CharsetUtil.UTF_8)).andReturn(29); + expect(buf.toString(27, 28, CharsetUtil.UTF_8)).andReturn("29"); expect(buf.capacity()).andReturn(30); replay(buf); @@ -128,7 +126,7 @@ public class ReadOnlyChannelBufferTest { assertEquals(102, roBBs[1].capacity()); assertTrue(roBBs[1].isReadOnly()); - assertEquals(29, roBuf.getString(27, 28, cb, CharsetUtil.UTF_8)); + assertEquals("29", roBuf.toString(27, 28, CharsetUtil.UTF_8)); assertEquals(30, roBuf.capacity()); verify(buf);