Renamed ChannelBuffers.wrappedBuffer(String, String) to ChannelBuffers.copiedBuffer which is correct

This commit is contained in:
Trustin Lee 2008-08-10 06:45:47 +00:00
parent ee62e8bbc0
commit 0c8361e21f
2 changed files with 17 additions and 17 deletions

View File

@ -60,20 +60,20 @@ import java.nio.charset.UnsupportedCharsetException;
* <h3>Creating a wrapped buffer</h3>
*
* Wrapped buffer is a buffer which is a view of one or more existing
* byte arrays, byte buffer and string. Any changes in the content of the
* original array or buffer will be reflected in the wrapped buffer. Various
* wrapper methods are provided and their name is all {@code wrappedBuffer()}.
* byte arrays and byte buffers. Any changes in the content of the original
* array or buffer will be reflected in the wrapped buffer. Various wrapper
* methods are provided and their name is all {@code wrappedBuffer()}.
* You might want to take a look at this method closely if you want to create
* a buffer which is composed of more than one array to reduce the number of
* memory copy.
*
* <h3>Creating a copied buffer</h3>
*
* Copied buffer is a deep copy of one or more existing byte arrays or byte
* buffer. Unlike a wrapped buffer, there's no shared data between the
* original arrays and the copied buffer. Various copy methods are provided
* and their name is all {@code copiedBuffer()}. It's also convenient to
* use this operation to merge multiple buffers into one buffer.
* Copied buffer is a deep copy of one or more existing byte arrays, byte
* buffers or a string. Unlike a wrapped buffer, there's no shared data
* between the original data and the copied buffer. Various copy methods are
* provided and their name is all {@code copiedBuffer()}. It's also convenient
* to use this operation to merge multiple buffers into one buffer.
*
* <h3>Miscellaneous utility methods</h3>
*
@ -347,14 +347,6 @@ public class ChannelBuffers {
return wrappedBuffer(wrappedBuffers);
}
public static ChannelBuffer wrappedBuffer(String string, String charsetName) {
try {
return wrappedBuffer(string.getBytes(charsetName));
} catch (UnsupportedEncodingException e) {
throw new UnsupportedCharsetException(charsetName);
}
}
public static ChannelBuffer copiedBuffer(byte[] array) {
return copiedBuffer(BIG_ENDIAN, array);
}
@ -466,6 +458,14 @@ public class ChannelBuffers {
return wrappedBuffer(copiedBuffers);
}
public static ChannelBuffer copiedBuffer(String string, String charsetName) {
try {
return wrappedBuffer(string.getBytes(charsetName));
} catch (UnsupportedEncodingException e) {
throw new UnsupportedCharsetException(charsetName);
}
}
public static ChannelBuffer unmodifiableBuffer(ChannelBuffer buffer) {
if (buffer instanceof ReadOnlyChannelBuffer) {
buffer = ((ReadOnlyChannelBuffer) buffer).unwrap();

View File

@ -74,6 +74,6 @@ public class StringEncoder implements ChannelDownstreamHandler {
}
write(context, e.getChannel(), e.getFuture(),
wrappedBuffer(String.valueOf(e.getMessage()), charsetName));
copiedBuffer(String.valueOf(e.getMessage()), charsetName));
}
}