org.glassfish.grizzly.Buffer.trim()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中org.glassfish.grizzly.Buffer.trim()方法的一些代码示例,展示了Buffer.trim()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.trim()方法的具体详情如下:
包路径:org.glassfish.grizzly.Buffer
类名称:Buffer
方法名:trim

Buffer.trim介绍

[英]Trim the buffer by reducing capacity to position, if possible. May return without changing capacity. Also resets the position to 0, like #flip().
[中]如有可能,通过减少定位容量来修剪缓冲器。可以在不改变容量的情况下返回。还将位置重置为0,如#flip()。

代码示例

代码示例来源:origin: com.ning/async-http-client

Buffer buffer = mm.allocate(512);
final byte[] b = new byte[512];
int read;
buffer.trim();
if (buffer.hasRemaining()) {
  final HttpContent content = requestPacket.httpContentBuilder()

代码示例来源:origin: com.ning/async-http-client

boolean last = false;
while (!last) {
  Buffer buffer = mm.allocate(PayloadGenerator.MAX_CHUNK_SIZE);
  buffer.allowBufferDispose(true);
  final long readBytes = bodyLocal.read(buffer.toByteBuffer());
  if (readBytes > 0) {
    buffer.position((int) readBytes);
    buffer.trim();
  } else {
    buffer.dispose();

代码示例来源:origin: com.ning/async-http-client

Buffer buffer = mm.allocate(MAX_CHUNK_SIZE);
buffer.allowBufferDispose(true);
if (readBytes > 0) {
  buffer.position((int) readBytes);
  buffer.trim();
} else {
  buffer.dispose();

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

public Buffer asClientCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeClientCookies(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asClientCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeClientCookies(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asClientCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeClientCookies(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

public Buffer asClientCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeClientCookies(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asClientCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeClientCookies(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public Buffer asServerCookieBuffer(MemoryManager memoryManager) {
  if (memoryManager == null) memoryManager =
      MemoryManager.DEFAULT_MEMORY_MANAGER;
  
  final Buffer buffer = memoryManager.allocate(4096);
  CookieSerializerUtils.serializeServerCookie(buffer, this);
  buffer.trim();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http2

@Override
public Buffer toBuffer(final MemoryManager memoryManager) {
  final Buffer buffer = memoryManager.allocate(FRAME_HEADER_SIZE + 4);
  serializeFrameHeader(buffer);
  buffer.putInt(windowSizeIncrement & 0x7fffffff);
  
  buffer.trim();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

@Override
public Buffer toBuffer(final MemoryManager memoryManager) {
  final Buffer buffer = memoryManager.allocate(FRAME_HEADER_SIZE + 8);
  serializeFrameHeader(buffer);
  buffer.putLong(opaqueData);
  buffer.trim();
  
  return buffer;
}

代码示例来源:origin: javaee/grizzly

@Override
public Buffer toBuffer(final MemoryManager memoryManager) {
  final Buffer buffer = memoryManager.allocate(FRAME_HEADER_SIZE + 4);
  serializeFrameHeader(buffer);
  buffer.putInt(windowSizeIncrement & 0x7fffffff);
  
  buffer.trim();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

@Override
public Buffer toBuffer(final MemoryManager memoryManager) {
  final Buffer buffer = memoryManager.allocate(FRAME_HEADER_SIZE + 8);
  serializeFrameHeader(buffer);
  buffer.putLong(opaqueData);
  buffer.trim();
  
  return buffer;
}

代码示例来源:origin: javaee/grizzly

@Override
public Buffer toBuffer(final MemoryManager memoryManager) {
  final Buffer buffer = memoryManager.allocate(FRAME_HEADER_SIZE + 4);
  serializeFrameHeader(buffer);
  buffer.putInt(windowSizeIncrement & 0x7fffffff);
  
  buffer.trim();
  return buffer;
}

相关文章