本文整理了Java中org.glassfish.grizzly.Buffer.clear()
方法的一些代码示例,展示了Buffer.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.clear()
方法的具体详情如下:
包路径:org.glassfish.grizzly.Buffer
类名称:Buffer
方法名:clear
[英]Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.
Invoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:
buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data
This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
[中]清除此缓冲区。位置设置为零,限制设置为容量,标记被丢弃。
在使用一系列通道读取或放置操作填充此缓冲区之前,请调用此方法。例如:
buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data
此方法实际上并没有擦除缓冲区中的数据,但它的命名方式与擦除数据的方式相同,因为它最常用于这种情况。
代码示例来源:origin: org.shoal/shoal-gms-impl
@Override
public Buffer clear() {
grizzlyBuffer.clear();
return this;
}
代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl
@Override
public Buffer clear() {
grizzlyBuffer.clear();
return this;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-http
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Reset current response.
*
* @throws IllegalStateException if the response has already been committed
*/
public void reset() {
if (committed) {
throw new IllegalStateException("Cannot reset the response as it has already been committed.");
}
compositeBuffer = null;
if (currentBuffer != null) {
currentBuffer.clear();
}
charsArrayLength = 0;
encoder = null;
}
代码示例来源:origin: javaee/grizzly
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: javaee/grizzly
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: javaee/grizzly
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: javaee/grizzly
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: javaee/grizzly
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-http-ajp
/**
* Process CPing request message.
* We send CPong response back as plain Grizzly {@link Buffer}.
*
* @param ctx
* @param message
* @return
* @throws IOException
*/
private NextAction processCPing(final FilterChainContext ctx,
final Buffer message) throws IOException {
message.clear();
message.put((byte) 'A');
message.put((byte) 'B');
message.putShort((short) 1);
message.put(AjpConstants.JK_AJP13_CPONG_REPLY);
message.flip();
// Write the buffer
ctx.write(message);
// Notify about response complete event
ctx.notifyDownstream(HttpServerFilter.RESPONSE_COMPLETE_EVENT);
return ctx.getStopAction();
}
代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly
private NextAction handleClientHandShake(FilterChainContext ctx, HttpContent content) {
final WebSocketHolder holder = WebSocketEngine.getEngine().getWebSocketHolder(getWebSocketConnection(ctx, content));
if (holder == null) {
content.recycle();
return ctx.getStopAction();
}
try {
final WebSocketResponse webSocketResponse = getWebSocketResponse((HttpResponsePacket) content.getHttpHeader());
holder.handshake.validateServerResponse(webSocketResponse);
holder.handshake.getResponseListener().onResponseHeaders(webSocketResponse.getHeaders());
holder.webSocket.onConnect();
} catch (HandshakeException e) {
holder.handshake.getResponseListener().onError(e);
content.getContent().clear();
return ctx.getStopAction();
}
if (content.getContent().hasRemaining()) {
return ctx.getRerunFilterAction();
} else {
content.recycle();
return ctx.getStopAction();
}
}
内容来源于网络,如有侵权,请联系作者删除!