Rename method and make it more clear thats an expert method. See #414 #415

This commit is contained in:
Norman Maurer 2012-06-29 12:28:08 +02:00 committed by Trustin Lee
parent 0ae4a64db2
commit ce90550f64
2 changed files with 5 additions and 4 deletions

View File

@ -577,7 +577,7 @@ public class CompositeByteBuf extends AbstractByteBuf {
/**
* Returns the {@link ByteBuf} portion of this {@link CompositeByteBuf} that
* contains the specified {@code index}. This is an expert method!
* contains the specified {@code index}. <strong>This is an expert method!</strong>
*
* <p>
* Please note that since a {@link CompositeByteBuf} is made up of
@ -585,13 +585,14 @@ public class CompositeByteBuf extends AbstractByteBuf {
* Instead, it only returns a portion of the composite buffer where the
* index is located
* </p>
*
*
* @param index The {@code index} to search for and include in the returned {@link ByteBuf}
* @return The {@link ByteBuf} that contains the specified {@code index}
* @throws IndexOutOfBoundsException when the specified {@code index} is
* less than zero, or larger than {@code capacity()}
*/
public ByteBuf getBufferFor(int index) throws IndexOutOfBoundsException {
public ByteBuf getBuffer(int index) throws IndexOutOfBoundsException {
if (index < 0 || index >= capacity()) {
throw new IndexOutOfBoundsException("Invalid index: " + index
+ " - Bytes needed: " + index + ", maximum is "

View File

@ -99,14 +99,14 @@ public abstract class AbstractCompositeChannelBufferTest extends
CompositeByteBuf buf = (CompositeByteBuf) Unpooled.wrappedBuffer(new byte[] { 1, 2, 3, 4, 5 }, new byte[] {4, 5, 6, 7, 8, 9, 26});
//Ensure that a random place will be fine
assertEquals(buf.getBufferFor(2).capacity(), 5);
assertEquals(buf.getBuffer(2).capacity(), 5);
//Loop through each byte
byte index = 0;
while (index < buf.capacity()) {
ByteBuf _buf = buf.getBufferFor(index++);
ByteBuf _buf = buf.getBuffer(index++);
assertNotNull(_buf);
assertTrue(_buf.capacity() > 0);
assertNotNull(_buf.getByte(0));