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

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

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

Buffer.get介绍

[英]Relative get method. Reads the byte at this buffer's current position, and then increments the position.
[中]相对get方法。读取该缓冲区当前位置的字节,然后递增该位置。

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public int read() throws IOException {
  if (position >= limit) {
    return -1;
  }
  final int result = buffer.get(position++) & 0xFF;
  if (isMovingPosition) {
    buffer.position(position);
  }
  return result;
}

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

public static PushPromiseFrame fromBuffer(final int flags,
                     final int streamId,
                     final Buffer buffer) {
  final PushPromiseFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  
  if (frame.isFlagSet(PADDED)) {
    frame.padLength = buffer.get() & 0xFF;
  }
  frame.promisedStreamId = buffer.getInt() & 0x7FFFFFFF;
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

/**
 * {@inheritDoc}
 */
@Override
public int read() throws IOException {
  if (position >= limit) {
    return -1;
  }
  final int result = buffer.get(position++) & 0xFF;
  if (isMovingPosition) {
    buffer.position(position);
  }
  return result;
}

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

public static PushPromiseFrame fromBuffer(final int flags,
                     final int streamId,
                     final Buffer buffer) {
  final PushPromiseFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  
  if (frame.isFlagSet(PADDED)) {
    frame.padLength = buffer.get() & 0xFF;
  }
  frame.promisedStreamId = buffer.getInt() & 0x7FFFFFFF;
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

/**
 * {@inheritDoc}
 */
@Override
public int read() throws IOException {
  if (position >= limit) {
    return -1;
  }
  final int result = buffer.get(position++) & 0xFF;
  if (isMovingPosition) {
    buffer.position(position);
  }
  return result;
}

代码示例来源: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: 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 PushPromiseFrame fromBuffer(final int flags,
                     final int streamId,
                     final Buffer buffer) {
  final PushPromiseFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  
  if (frame.isFlagSet(PADDED)) {
    frame.padLength = buffer.get() & 0xFF;
  }
  frame.promisedStreamId = buffer.getInt() & 0x7FFFFFFF;
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

/**
 * {@inheritDoc}
 */
@Override
public int read() throws IOException {
  if (position >= limit) {
    return -1;
  }
  final int result = buffer.get(position++) & 0xFF;
  if (isMovingPosition) {
    buffer.position(position);
  }
  return result;
}

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

public static PushPromiseFrame fromBuffer(final int flags,
                     final int streamId,
                     final Buffer buffer) {
  final PushPromiseFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  
  if (frame.isFlagSet(PADDED)) {
    frame.padLength = buffer.get() & 0xFF;
  }
  frame.promisedStreamId = buffer.getInt() & 0x7FFFFFFF;
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

相关文章