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
parent f8093408e4
commit 07095a41f4
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 * 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> * <p>
* Please note that since a {@link CompositeByteBuf} is made up of * 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 * Instead, it only returns a portion of the composite buffer where the
* index is located * index is located
* </p> * </p>
*
* *
* @param index The {@code index} to search for and include in the returned {@link ByteBuf} * @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} * @return The {@link ByteBuf} that contains the specified {@code index}
* @throws IndexOutOfBoundsException when the specified {@code index} is * @throws IndexOutOfBoundsException when the specified {@code index} is
* less than zero, or larger than {@code capacity()} * 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()) { if (index < 0 || index >= capacity()) {
throw new IndexOutOfBoundsException("Invalid index: " + index throw new IndexOutOfBoundsException("Invalid index: " + index
+ " - Bytes needed: " + index + ", maximum is " + " - 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}); 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 //Ensure that a random place will be fine
assertEquals(buf.getBufferFor(2).capacity(), 5); assertEquals(buf.getBuffer(2).capacity(), 5);
//Loop through each byte //Loop through each byte
byte index = 0; byte index = 0;
while (index < buf.capacity()) { while (index < buf.capacity()) {
ByteBuf _buf = buf.getBufferFor(index++); ByteBuf _buf = buf.getBuffer(index++);
assertNotNull(_buf); assertNotNull(_buf);
assertTrue(_buf.capacity() > 0); assertTrue(_buf.capacity() > 0);
assertNotNull(_buf.getByte(0)); assertNotNull(_buf.getByte(0));