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

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

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

Buffer.remaining介绍

[英]Returns the number of elements between the current position and the limit.
[中]返回当前位置和限制之间的元素数。

代码示例

代码示例来源: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 void read(Buffer source, Appendable destination) {
  for (int i = 0, len = source.remaining(); i < len; i++) {
    char c = (char) (source.get() & 0xff);
    try {
      destination.append(c);
    } catch (IOException e) {
      throw new RuntimeException
          ("Error appending to the destination", e);
    }
  }
}

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

public static Http2Frame fromBuffer(final int streamId, final Buffer frameBuffer) {
  PriorityFrame frame = create();
  frame.setStreamId(streamId);
  frame.length = frameBuffer.remaining();
  final int dependency = frameBuffer.getInt();
  frame.streamDependency = dependency & 0x7fffffff;
  frame.isExclusive = (dependency & 1L << 31) != 0;  // last bit is set
  frame.weight = frameBuffer.get() & 0xff;
  frame.setFrameBuffer(frameBuffer);
  
  return frame;
}

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

private Buffer splitOutputBufferIfNeeded(final Buffer buffer,
    final int length) {
  if (length == buffer.remaining()) {
    return null;
  }
  return buffer.split(buffer.position() + length);
}

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

public static Http2Frame fromBuffer(final int streamId, final Buffer frameBuffer) {
  PriorityFrame frame = create();
  frame.setStreamId(streamId);
  frame.length = frameBuffer.remaining();
  final int dependency = frameBuffer.getInt();
  frame.streamDependency = dependency & 0x7fffffff;
  frame.isExclusive = (dependency & 1L << 31) != 0;  // last bit is set
  frame.weight = frameBuffer.get() & 0xff;
  frame.setFrameBuffer(frameBuffer);
  
  return frame;
}

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

public void read(Buffer source, Appendable destination) {
  for (int i = 0, len = source.remaining(); i < len; i++) {
    char c = (char) (source.get() & 0xff);
    try {
      destination.append(c);
    } catch (IOException e) {
      throw new RuntimeException
          ("Error appending to the destination", e);
    }
  }
}

代码示例来源: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 Http2Frame fromBuffer(final int streamId, final Buffer frameBuffer) {
  PriorityFrame frame = create();
  frame.setStreamId(streamId);
  frame.length = frameBuffer.remaining();
  final int dependency = frameBuffer.getInt();
  frame.streamDependency = dependency & 0x7fffffff;
  frame.isExclusive = (dependency & 1L << 31) != 0;  // last bit is set
  frame.weight = frameBuffer.get() & 0xff;
  frame.setFrameBuffer(frameBuffer);
  
  return frame;
}

代码示例来源: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: org.glassfish.grizzly/grizzly-http2

public void read(Buffer source, Appendable destination) {
  for (int i = 0, len = source.remaining(); i < len; i++) {
    char c = (char) (source.get() & 0xff);
    try {
      destination.append(c);
    } catch (IOException e) {
      throw new RuntimeException
          ("Error appending to the destination", e);
    }
  }
}

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

private Buffer splitOutputBufferIfNeeded(final Buffer buffer,
    final int length) {
  if (length == buffer.remaining()) {
    return null;
  }
  return buffer.split(buffer.position() + length);
}

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

public static Http2Frame fromBuffer(final int streamId, final Buffer frameBuffer) {
  PriorityFrame frame = create();
  frame.setStreamId(streamId);
  frame.length = frameBuffer.remaining();
  final int dependency = frameBuffer.getInt();
  frame.streamDependency = dependency & 0x7fffffff;
  frame.isExclusive = (dependency & 1L << 31) != 0;  // last bit is set
  frame.weight = frameBuffer.get() & 0xff;
  frame.setFrameBuffer(frameBuffer);
  
  return frame;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-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

public void read(Buffer source, Appendable destination) {
  for (int i = 0, len = source.remaining(); i < len; i++) {
    char c = (char) (source.get() & 0xff);
    try {
      destination.append(c);
    } catch (IOException e) {
      throw new RuntimeException
          ("Error appending to the destination", e);
    }
  }
}

代码示例来源: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 Http2Frame fromBuffer(final int streamId, final Buffer frameBuffer) {
  PriorityFrame frame = create();
  frame.setStreamId(streamId);
  frame.length = frameBuffer.remaining();
  final int dependency = frameBuffer.getInt();
  frame.streamDependency = dependency & 0x7fffffff;
  frame.isExclusive = (dependency & 1L << 31) != 0;  // last bit is set
  frame.weight = frameBuffer.get() & 0xff;
  frame.setFrameBuffer(frameBuffer);
  
  return frame;
}

代码示例来源:origin: org.apache.apex/apex-shaded-ning19

@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

public void read(Buffer source, Appendable destination) {
  for (int i = 0, len = source.remaining(); i < len; i++) {
    char c = (char) (source.get() & 0xff);
    try {
      destination.append(c);
    } catch (IOException e) {
      throw new RuntimeException
          ("Error appending to the destination", e);
    }
  }
}

相关文章