本文整理了Java中org.glassfish.grizzly.Buffer.put()
方法的一些代码示例,展示了Buffer.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.put()
方法的具体详情如下:
包路径:org.glassfish.grizzly.Buffer
类名称:Buffer
方法名:put
[英]Relative put method (optional operation).
Writes the given byte into this buffer at the current position, and then increments the position.
[中]相对put方法(可选操作)。
在当前位置将给定字节写入此缓冲区,然后递增该位置。
代码示例来源:origin: apache/incubator-dubbo
@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
Connection<?> connection = context.getConnection();
GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
try {
ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
Object msg = context.getMessage();
codec.encode(channel, channelBuffer, msg);
GrizzlyChannel.removeChannelIfDisconnected(connection);
Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
buffer.put(channelBuffer.toByteBuffer());
buffer.flip();
buffer.allowBufferDispose(true);
context.setMessage(buffer);
} finally {
GrizzlyChannel.removeChannelIfDisconnected(connection);
}
return context.getInvokeAction();
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
protected void serializeFrameHeader(final Buffer buffer) {
assert buffer.remaining() >= Http2Frame.FRAME_HEADER_SIZE;
buffer.putInt(
((getLength() & 0xffffff) << 8) |
getType());
buffer.put((byte) getFlags());
buffer.putInt(getStreamId());
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
Connection<?> connection = context.getConnection();
GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
try {
ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
Object msg = context.getMessage();
codec.encode(channel, channelBuffer, msg);
GrizzlyChannel.removeChannelIfDisconnected(connection);
Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
buffer.put(channelBuffer.toByteBuffer());
buffer.flip();
buffer.allowBufferDispose(true);
context.setMessage(buffer);
} finally {
GrizzlyChannel.removeChannelIfDisconnected(connection);
}
return context.getInvokeAction();
}
代码示例来源:origin: com.ning/async-http-client
buffer = mm.reallocate(buffer, buffer.capacity() + 512);
buffer.put(b, 0, read);
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
@Override
public void write(byte data) throws IOException {
ensureBufferCapacity(1);
buffer.put(data);
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
@Override
public void write(int b) throws IOException {
ensureCapacity(1);
currentBuffer.put((byte) b);
}
代码示例来源:origin: javaee/grizzly
@Override
public void write(byte data) throws IOException {
ensureBufferCapacity(1);
buffer.put(data);
}
代码示例来源:origin: javaee/grizzly
@Override
public void write(byte data) throws IOException {
ensureBufferCapacity(1);
buffer.put(data);
}
代码示例来源:origin: javaee/grizzly
static void put(Buffer dstBuffer, String s) {
final int size = s.length();
if (dstBuffer.remaining() < size) {
throw new BufferOverflowException();
}
for (int i = 0; i < size; i++) {
dstBuffer.put((byte) s.charAt(i));
}
}
代码示例来源:origin: javaee/grizzly
public static Buffer put(final MemoryManager memoryManager,
Buffer dstBuffer, final byte value) {
if (!dstBuffer.hasRemaining()) {
dstBuffer = resizeBuffer(memoryManager, dstBuffer, 1);
}
dstBuffer.put(value);
return dstBuffer;
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
private void putCharB(int index, char value) {
activeBuffer.put(toActiveBufferPos(index), Bits.char1(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.char0(value));
}
代码示例来源:origin: javaee/grizzly
private void putShortB(int index, short value) {
activeBuffer.put(toActiveBufferPos(index), Bits.short1(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.short0(value));
}
代码示例来源:origin: javaee/grizzly
private void putCharB(int index, char value) {
activeBuffer.put(toActiveBufferPos(index), Bits.char1(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.char0(value));
}
代码示例来源:origin: javaee/grizzly
private void putCharB(int index, char value) {
activeBuffer.put(toActiveBufferPos(index), Bits.char1(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.char0(value));
}
代码示例来源:origin: javaee/grizzly
private void putIntB(int index, int value) {
activeBuffer.put(toActiveBufferPos(index), Bits.int3(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.int2(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.int1(value));
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.int0(value));
}
代码示例来源:origin: javaee/grizzly
private void putCharL(int index, char value) {
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.char0(value));
checkIndex(--index);
activeBuffer.put(toActiveBufferPos(index), Bits.char1(value));
}
代码示例来源:origin: javaee/grizzly
private void putIntL(int index, int value) {
index += 3;
checkIndex(index);
activeBuffer.put(toActiveBufferPos(index), Bits.int3(value));
checkIndex(--index);
activeBuffer.put(toActiveBufferPos(index), Bits.int2(value));
checkIndex(--index);
activeBuffer.put(toActiveBufferPos(index), Bits.int1(value));
checkIndex(--index);
activeBuffer.put(toActiveBufferPos(index), Bits.int0(value));
}
代码示例来源:origin: javaee/grizzly
private void putCharL(int index, char value) {
checkIndex(++index);
activeBuffer.put(toActiveBufferPos(index), Bits.char0(value));
checkIndex(--index);
activeBuffer.put(toActiveBufferPos(index), Bits.char1(value));
}
代码示例来源:origin: javaee/grizzly
static Buffer copy(final MemoryManager memoryManager,
final Buffer buffer) {
final Buffer tmpBuf = memoryManager.allocate(buffer.remaining());
tmpBuf.put(buffer);
return tmpBuf.flip();
}
代码示例来源:origin: javaee/grizzly
public void append(final BufferChunk bc) {
final int oldPos = buffer.position();
final int oldLim = buffer.limit();
final int srcLen = bc.getLength()
;
Buffers.setPositionLimit(buffer, end, end + srcLen);
buffer.put(bc.getBuffer(), bc.getStart(), srcLen);
Buffers.setPositionLimit(buffer, oldPos, oldLim);
end += srcLen;
}
内容来源于网络,如有侵权,请联系作者删除!