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

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

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

Buffer.putShort介绍

[英]Absolute put method for writing a short value  (optional operation).

Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index.
[中]用于写入短值的绝对put方法(可选操作)。
按当前字节顺序将包含给定短值的两个字节写入给定索引处的缓冲区。

代码示例

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

@Override
public Buffer putShort(final int index, final short value) {
  grizzlyBuffer.putShort(index, value);
  return this;
}

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

@Override
public Buffer putShort(final short value) {
  grizzlyBuffer.putShort(value);
  return this;
}

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

@Override
public Buffer putShort(final short value) {
  grizzlyBuffer.putShort(value);
  return this;
}

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

@Override
public Buffer putShort(final int index, final short value) {
  grizzlyBuffer.putShort(index, value);
  return this;
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putShort(final MemoryManager memoryManager,
      Buffer dstBuffer, final int value) {
    if (dstBuffer.remaining() < 2) {
      dstBuffer = resizeBuffer(memoryManager, dstBuffer, 2);
    }
    dstBuffer.putShort((short) value);

    return dstBuffer;
  }
}

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

private static Buffer putBytes(final MemoryManager memoryManager,
    Buffer dstBuffer, final byte[] bytes) {
  final int size = bytes.length;
  // Don't forget the terminating \0 (that's why "+ 1")
  if (dstBuffer.remaining() < size + 2 + 1) {
    dstBuffer = resizeBuffer(memoryManager, dstBuffer, size + 2 + 1);
  }
  dstBuffer.putShort((short) size);
  dstBuffer = put(memoryManager, dstBuffer, bytes);
  // Don't forget the terminating \0
  dstBuffer.put((byte) 0);
  return dstBuffer;
}

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

/**
 * {@inheritDoc}
 */
@Override
public void writeShort(final short data) throws IOException {
  if (isOutputBuffered) {
    output.ensureBufferCapacity(2);
    output.getBuffer().putShort(data);
  } else {
    output.write((byte) ((data >>> 8) & 0xFF));
    output.write((byte) ((data) & 0xFF));
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public void writeShort(final short data) throws IOException {
  if (isOutputBuffered) {
    output.ensureBufferCapacity(2);
    output.getBuffer().putShort(data);
  } else {
    output.write((byte) ((data >>> 8) & 0xFF));
    output.write((byte) ((data) & 0xFF));
  }
}

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

private static Buffer putBytes(final MemoryManager memoryManager,
    Buffer dstBuffer, final byte[] bytes) {
  final int size = bytes.length;
  // Don't forget the terminating \0 (that's why "+ 1")
  if (dstBuffer.remaining() < size + 2 + 1) {
    dstBuffer = resizeBuffer(memoryManager, dstBuffer, size + 2 + 1);
  }
  dstBuffer.putShort((short) size);
  dstBuffer = put(memoryManager, dstBuffer, bytes);
  // Don't forget the terminating \0
  dstBuffer.put((byte) 0);
  return dstBuffer;
}

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

private static Buffer putBytes(final MemoryManager memoryManager,
    Buffer dstBuffer, final byte[] bytes) {
  final int size = bytes.length;
  // Don't forget the terminating \0 (that's why "+ 1")
  if (dstBuffer.remaining() < size + 2 + 1) {
    dstBuffer = resizeBuffer(memoryManager, dstBuffer, size + 2 + 1);
  }
  dstBuffer.putShort((short) size);
  dstBuffer = put(memoryManager, dstBuffer, bytes);
  // Don't forget the terminating \0
  dstBuffer.put((byte) 0);
  return dstBuffer;
}

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

private void sendEndResponse(final FilterChainContext ctx) throws IOException {
  final Connection connection = ctx.getConnection();
  final MemoryManager mm = connection.getTransport().getMemoryManager();
  final Buffer buffer = mm.allocate(6);
  buffer.put((byte) 'A');
  buffer.put((byte) 'B');
  buffer.putShort((short) 2);
  buffer.put(AjpConstants.JK_AJP13_END_RESPONSE);
  buffer.put((byte) 1);
  buffer.flip();
  buffer.allowBufferDispose(true);
  ctx.write(buffer);
}

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

private void sendEndResponse(final FilterChainContext ctx) throws IOException {
  final Connection connection = ctx.getConnection();
  final MemoryManager mm = connection.getTransport().getMemoryManager();
  final Buffer buffer = mm.allocate(6);
  buffer.put((byte) 'A');
  buffer.put((byte) 'B');
  buffer.putShort((short) 2);
  buffer.put(AjpConstants.JK_AJP13_END_RESPONSE);
  buffer.put((byte) 1);
  buffer.flip();
  buffer.allowBufferDispose(true);
  ctx.write(buffer);
}

相关文章