Resolved issue: NETTY-298 Make ChannelBuffer setter/writer methods to accept int for narrower types
This commit is contained in:
parent
a3bae359bd
commit
5558f02003
@ -171,8 +171,8 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
dst.writerIndex(dst.writerIndex() + length);
|
||||
}
|
||||
|
||||
public void setChar(int index, char value) {
|
||||
setShort(index, (short) value);
|
||||
public void setChar(int index, int value) {
|
||||
setShort(index, value);
|
||||
}
|
||||
|
||||
public void setFloat(int index, float value) {
|
||||
@ -398,11 +398,11 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return newReaderIndex - oldReaderIndex;
|
||||
}
|
||||
|
||||
public void writeByte(byte value) {
|
||||
public void writeByte(int value) {
|
||||
setByte(writerIndex ++, value);
|
||||
}
|
||||
|
||||
public void writeShort(short value) {
|
||||
public void writeShort(int value) {
|
||||
setShort(writerIndex, value);
|
||||
writerIndex += 2;
|
||||
}
|
||||
@ -422,8 +422,8 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
writerIndex += 8;
|
||||
}
|
||||
|
||||
public void writeChar(char value) {
|
||||
writeShort((short) value);
|
||||
public void writeChar(int value) {
|
||||
writeShort(value);
|
||||
}
|
||||
|
||||
public void writeFloat(float value) {
|
||||
|
@ -88,7 +88,7 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
((long) array[index+7] & 0xff) << 0;
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 8);
|
||||
array[index+1] = (byte) (value >>> 0);
|
||||
}
|
||||
|
@ -151,12 +151,12 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
dst.put(data);
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
buffer.put(index, value);
|
||||
public void setByte(int index, int value) {
|
||||
buffer.put(index, (byte) value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
buffer.putShort(index, value);
|
||||
public void setShort(int index, int value) {
|
||||
buffer.putShort(index, (short) value);
|
||||
}
|
||||
|
||||
public void setMedium(int index, int value) {
|
||||
|
@ -718,7 +718,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
|
||||
/**
|
||||
* Sets the specified byte at the specified absolute {@code index} in this
|
||||
* buffer.
|
||||
* buffer. The 24 high-order bits of the specified value are ignored.
|
||||
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
||||
* this buffer.
|
||||
*
|
||||
@ -726,11 +726,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* if the specified {@code index} is less than {@code 0} or
|
||||
* {@code index + 1} is greater than {@code this.capacity}
|
||||
*/
|
||||
void setByte(int index, byte value);
|
||||
void setByte(int index, int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 16-bit short integer at the specified absolute
|
||||
* {@code index} in this buffer.
|
||||
* {@code index} in this buffer. The 16 high-order bits of the specified
|
||||
* value are ignored.
|
||||
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
||||
* this buffer.
|
||||
*
|
||||
@ -738,7 +739,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* if the specified {@code index} is less than {@code 0} or
|
||||
* {@code index + 2} is greater than {@code this.capacity}
|
||||
*/
|
||||
void setShort(int index, short value);
|
||||
void setShort(int index, int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 24-bit medium integer at the specified absolute
|
||||
@ -780,6 +781,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
/**
|
||||
* Sets the specified 2-byte UTF-16 character at the specified absolute
|
||||
* {@code index} in this buffer.
|
||||
* The 16 high-order bits of the specified value are ignored.
|
||||
* This method does not modify {@code readerIndex} or {@code writerIndex} of
|
||||
* this buffer.
|
||||
*
|
||||
@ -787,7 +789,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* if the specified {@code index} is less than {@code 0} or
|
||||
* {@code index + 2} is greater than {@code this.capacity}
|
||||
*/
|
||||
void setChar(int index, char value);
|
||||
void setChar(int index, int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 32-bit floating-point number at the specified
|
||||
@ -1244,21 +1246,22 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
/**
|
||||
* Sets the specified byte at the current {@code writerIndex}
|
||||
* and increases the {@code writerIndex} by {@code 1} in this buffer.
|
||||
* The 24 high-order bits of the specified value are ignored.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if {@code this.writableBytes} is less than {@code 1}
|
||||
*/
|
||||
void writeByte(byte value);
|
||||
void writeByte(int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 16-bit short integer at the current
|
||||
* {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
|
||||
* in this buffer.
|
||||
* in this buffer. The 16 high-order bits of the specified value are ignored.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if {@code this.writableBytes} is less than {@code 2}
|
||||
*/
|
||||
void writeShort(short value);
|
||||
void writeShort(int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 24-bit medium integer at the current
|
||||
@ -1292,12 +1295,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
/**
|
||||
* Sets the specified 2-byte UTF-16 character at the current
|
||||
* {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
|
||||
* in this buffer.
|
||||
* in this buffer. The 16 high-order bits of the specified value are ignored.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if {@code this.writableBytes} is less than {@code 2}
|
||||
*/
|
||||
void writeChar(char value);
|
||||
void writeChar(int value);
|
||||
|
||||
/**
|
||||
* Sets the specified 32-bit floating point number at the current
|
||||
|
@ -307,12 +307,12 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
components[componentId].setByte(index - indices[componentId], value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 2 <= indices[componentId + 1]) {
|
||||
components[componentId].setShort(index - indices[componentId], value);
|
||||
|
@ -128,11 +128,11 @@ public class DuplicatedChannelBuffer extends AbstractChannelBuffer implements Wr
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
||||
|
@ -156,11 +156,11 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
||||
@ -199,13 +199,13 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(byte value) {
|
||||
public void writeByte(int value) {
|
||||
ensureWritableBytes(1);
|
||||
super.writeByte(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeShort(short value) {
|
||||
public void writeShort(int value) {
|
||||
ensureWritableBytes(2);
|
||||
super.writeShort(value);
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
return out.write(ByteBuffer.wrap(array, index, length));
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
array[index] = value;
|
||||
public void setByte(int index, int value) {
|
||||
array[index] = (byte) value;
|
||||
}
|
||||
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
|
@ -88,7 +88,7 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
((long) array[index+7] & 0xff) << 56;
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 0);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
|
@ -148,12 +148,12 @@ public class SlicedChannelBuffer extends AbstractChannelBuffer implements Wrappe
|
||||
buffer.getBytes(index + adjustment, dst);
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
checkIndex(index);
|
||||
buffer.setByte(index + adjustment, value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
checkIndex(index, 2);
|
||||
buffer.setShort(index + adjustment, value);
|
||||
}
|
||||
|
@ -142,12 +142,12 @@ public class TruncatedChannelBuffer extends AbstractChannelBuffer implements Wra
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
checkIndex(index);
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
checkIndex(index, 2);
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void setByte(int index, byte value) {
|
||||
public void setByte(int index, int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@ -503,11 +503,11 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void setShort(int index, short value) {
|
||||
public void setShort(int index, int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void setChar(int index, char value) {
|
||||
public void setChar(int index, int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@ -613,7 +613,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void writeByte(byte value) {
|
||||
public void writeByte(int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@ -674,11 +674,11 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void writeShort(short value) {
|
||||
public void writeShort(int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void writeChar(char value) {
|
||||
public void writeChar(int value) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user