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

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

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

Buffer.split介绍

[英]Split up the buffer into two parts: [0..splitPosition) and [splitPosition, capacity). This Buffer will represent the first part: [0..splitPosition) and returned Buffer will represent the second part: [splitPosition, capacity). Splitting a buffer will reset the mark if the mark is greater than or equal to the splitPosition.
[中]将缓冲区拆分为两部分:[0..splitPosition]和[splitPosition,capacity]。此缓冲区将表示第一部分:[0..splitPosition],返回的缓冲区将表示第二部分:[splitPosition,capacity]。如果标记大于或等于[$0$],拆分缓冲区将重置标记。

代码示例

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

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

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

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

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

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

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

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

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

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

代码示例来源: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 ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  return frame;
}

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

public static ContinuationFrame fromBuffer(final int flags,
                      final int streamId,
                      final Buffer buffer) {
  final ContinuationFrame frame = create();
  frame.setFlags(flags);
  frame.setStreamId(streamId);
  frame.compressedHeaders = buffer.split(buffer.position());
  frame.setFrameBuffer(buffer);
  
  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

@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));
}

相关文章