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

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

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

Buffer.duplicate介绍

[英]Creates a new Buffer that shares this buffer's content.

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffer's position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
[中]创建共享此缓冲区内容的新Buffer
新缓冲区的内容将是此缓冲区的内容。此缓冲区内容的更改将在新缓冲区中可见,反之亦然;两个缓冲区的位置、限制和标记值将是独立的。
新缓冲区的容量、限制、位置和标记值将与此缓冲区的相同。当且仅当此缓冲区为直接缓冲区时,新缓冲区将为直接缓冲区;当且仅当此缓冲区为只读缓冲区时,新缓冲区将为只读缓冲区。

代码示例

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

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

private BuffersBuffer duplicateFrom(final BuffersBuffer that) {
  this.memoryManager = that.memoryManager;
  final Buffer[] ba = new Buffer[that.buffers.length];
  for (int i = 0, len = that.buffersSize; i < len; i++) {
    ba[i] = that.buffers[i].duplicate();
  }
  initBuffers(ba, that.buffersSize);
  System.arraycopy(that.bufferBounds, 0, this.bufferBounds, 0, that.buffersSize);
  
  this.position = that.position;
  this.limit = that.limit;
  this.capacity = that.capacity;
  this.isReadOnly = that.isReadOnly;
  this.byteOrder = that.byteOrder;
  
  return this;
}

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

private BuffersBuffer duplicateFrom(final BuffersBuffer that) {
  this.memoryManager = that.memoryManager;
  final Buffer[] ba = new Buffer[that.buffers.length];
  for (int i = 0, len = that.buffersSize; i < len; i++) {
    ba[i] = that.buffers[i].duplicate();
  }
  initBuffers(ba, that.buffersSize);
  System.arraycopy(that.bufferBounds, 0, this.bufferBounds, 0, that.buffersSize);
  
  this.position = that.position;
  this.limit = that.limit;
  this.capacity = that.capacity;
  this.isReadOnly = that.isReadOnly;
  this.byteOrder = that.byteOrder;
  
  return this;
}

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

private BuffersBuffer duplicateFrom(final BuffersBuffer that) {
  this.memoryManager = that.memoryManager;
  final Buffer[] ba = new Buffer[that.buffers.length];
  for (int i = 0, len = that.buffersSize; i < len; i++) {
    ba[i] = that.buffers[i].duplicate();
  }
  initBuffers(ba, that.buffersSize);
  System.arraycopy(that.bufferBounds, 0, this.bufferBounds, 0, that.buffersSize);
  
  this.position = that.position;
  this.limit = that.limit;
  this.capacity = that.capacity;
  this.isReadOnly = that.isReadOnly;
  this.byteOrder = that.byteOrder;
  
  return this;
}

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

private BuffersBuffer duplicateFrom(final BuffersBuffer that) {
  this.memoryManager = that.memoryManager;
  final Buffer[] ba = new Buffer[that.buffers.length];
  for (int i = 0, len = that.buffersSize; i < len; i++) {
    ba[i] = that.buffers[i].duplicate();
  }
  initBuffers(ba, that.buffersSize);
  System.arraycopy(that.bufferBounds, 0, this.bufferBounds, 0, that.buffersSize);
  
  this.position = that.position;
  this.limit = that.limit;
  this.capacity = that.capacity;
  this.isReadOnly = that.isReadOnly;
  this.byteOrder = that.byteOrder;
  
  return this;
}

代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl

@Override
public Buffer duplicate() {
  final GMSBufferWrapper wrapper = new GMSBufferWrapper();
  if (grizzlyBuffer != null) {
    wrapper.wrap(grizzlyBuffer.duplicate());
  }
  return wrapper;
}

代码示例来源:origin: org.shoal/shoal-gms-impl

@Override
public Buffer duplicate() {
  final GMSBufferWrapper wrapper = new GMSBufferWrapper();
  if (grizzlyBuffer != null) {
    wrapper.wrap(grizzlyBuffer.duplicate());
  }
  return wrapper;
}

代码示例来源:origin: org.glassfish.main.web/web-core

/**
 * Read post body in an array.
 */
protected int readPostBody(byte body[], int len)
    throws IOException {
  Buffer b = coyoteRequest.getPostBody(len).duplicate();
  final int length = b.limit() - b.position();
  b.get(body, b.position(), length);
  return length;
}

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

@Test
public void testToStringContent2() {
  final Charset utf16 = Charset.forName("UTF-16");
  
  final String msg = "\u043F\u0440\u0438\u0432\u0435\u0442";
  final Buffer msgBuffer = Buffers.wrap(mm, msg, utf16);
  final Buffer b1 = msgBuffer.duplicate();
  final Buffer b2 = b1.split(3);
  
  final CompositeBuffer composite = CompositeBuffer.newBuffer(
      mm, b1, b2);
  assertTrue(composite.equals(msgBuffer));
  assertEquals(msg, composite.toStringContent(utf16));
}

相关文章