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

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

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

Buffer.position介绍

[英]Returns this buffer's position.
[中]返回此缓冲区的位置。

代码示例

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

@Override
public byte[] getResponseBodyAsBytes() throws IOException {
  final byte[] responseBodyBytes = new byte[responseBody.remaining()];
  final int origPos = responseBody.position();
  responseBody.get(responseBodyBytes);
  responseBody.position(origPos);
  return responseBodyBytes;
}

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

@Override
public String getResponseBodyExcerpt(int maxLength, String charset) throws IOException {
  final int len = Math.min(responseBody.remaining(), maxLength);
  final int pos = responseBody.position();
  return responseBody.toStringContent(getCharset(charset), pos, len + pos);
}

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

public static void setPositionLimit(final Buffer buffer,
    final int position, final int limit) {
  buffer.limit(limit);
  buffer.position(position);
}

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

@Override
public ByteBufferWrapper put(final Buffer src) {
  put(src, src.position(), src.remaining());
  src.position(src.limit());
  return this;
}

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

private static void fill(Buffer src, int size, ByteBuffer dstByteBuffer)
{
  dstByteBuffer.limit(size);
  int oldPos = src.position();
  src.get(dstByteBuffer);
  dstByteBuffer.position(0);
  src.position(oldPos);
}

代码示例来源: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

@Override
public ByteBufferWrapper put(final Buffer src) {
  put(src, src.position(), src.remaining());
  src.position(src.limit());
  return this;
}

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

private void recalcIndex(final int index) {
  final int idx = index < bufferBounds[0]
      ? 0 
      : ArrayUtils.binarySearch(bufferBounds, 0,
      buffersSize - 1, index + 1);
  
  activeBuffer = buffers[idx];
  upperBound = bufferBounds[idx];
  lowerBound = upperBound - activeBuffer.remaining();
  lastSegmentIndex = idx;
  activeBufferLowerBound = lowerBound - activeBuffer.position();
}

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

public static void setPositionLimit(final Buffer buffer,
    final int position, final int limit) {
  buffer.limit(limit);
  buffer.position(position);
}

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

@Override
public byte[] getBodyPartBytes() {
  byte[] bytes = contentBytes.get();
  if (bytes != null) {
    return bytes;
  }
  final Buffer b = content.getContent();
  final int origPos = b.position();
  bytes = new byte[b.remaining()];
  b.get(bytes);
  b.flip();
  b.position(origPos);
  contentBytes.compareAndSet(null, bytes);
  return bytes;
}

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

private static void fill(Buffer src, int size, ByteBuffer dstByteBuffer)
{
  dstByteBuffer.limit(size);
  int oldPos = src.position();
  src.get(dstByteBuffer);
  dstByteBuffer.position(0);
  src.position(oldPos);
}

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

@Override
public BuffersBuffer put(Buffer src) {
  put(src, src.position(), src.remaining());
  src.position(src.limit());
  return this;
}

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

private void recalcIndex(final int index) {
  final int idx = index < bufferBounds[0]
      ? 0 
      : ArrayUtils.binarySearch(bufferBounds, 0,
      buffersSize - 1, index + 1);
  
  activeBuffer = buffers[idx];
  upperBound = bufferBounds[idx];
  lowerBound = upperBound - activeBuffer.remaining();
  lastSegmentIndex = idx;
  activeBufferLowerBound = lowerBound - activeBuffer.position();
}

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

public static void setPositionLimit(final Buffer buffer,
    final int position, final int limit) {
  buffer.limit(limit);
  buffer.position(position);
}

代码示例来源:origin: io.gatling/async-http-client

@Override
public byte[] getResponseBodyAsBytes() throws IOException {
  final byte[] responseBodyBytes = new byte[responseBody.remaining()];
  final int origPos = responseBody.position();
  responseBody.get(responseBodyBytes);
  responseBody.position(origPos);
  return responseBodyBytes;
}

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

private static void fill(Buffer src, int size, ByteBuffer dstByteBuffer)
{
  dstByteBuffer.limit(size);
  int oldPos = src.position();
  src.get(dstByteBuffer);
  dstByteBuffer.position(0);
  src.position(oldPos);
}

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

@Override
public HeapBuffer put(final Buffer src) {
  put(src, src.position(), src.remaining());
  src.position(src.limit());
  return this;
}

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

private void recalcIndex(final int index) {
  final int idx = index < bufferBounds[0]
      ? 0 
      : ArrayUtils.binarySearch(bufferBounds, 0,
      buffersSize - 1, index + 1);
  
  activeBuffer = buffers[idx];
  upperBound = bufferBounds[idx];
  lowerBound = upperBound - activeBuffer.remaining();
  lastSegmentIndex = idx;
  activeBufferLowerBound = lowerBound - activeBuffer.position();
}

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

public static void setPositionLimit(final Buffer buffer,
    final int position, final int limit) {
  buffer.limit(limit);
  buffer.position(position);
}

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

@Override
public byte[] getResponseBodyAsBytes() throws IOException {
  final byte[] responseBodyBytes = new byte[responseBody.remaining()];
  final int origPos = responseBody.position();
  responseBody.get(responseBodyBytes);
  responseBody.position(origPos);
  return responseBodyBytes;
}

相关文章