本文整理了Java中com.couchbase.client.deps.io.netty.buffer.ByteBuf.writerIndex()
方法的一些代码示例,展示了ByteBuf.writerIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.writerIndex()
方法的具体详情如下:
包路径:com.couchbase.client.deps.io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:writerIndex
[英]Returns the writerIndex of this buffer.
[中]
代码示例来源:origin: com.couchbase.client/core-io
/**
* Returns the number of written bytes by this stream so far.
*/
public int writtenBytes() {
return buffer.writerIndex() - startIndex;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public final ByteBuf writerIndex(int writerIndex) {
buf.writerIndex(writerIndex);
return this;
}
代码示例来源:origin: com.couchbase.client/core-io
private void checkIndex(int index, int length) {
if (index + length > buffer.writerIndex()) {
throw REPLAY;
}
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public ByteBuf writerIndex(int writerIndex) {
buf.writerIndex(writerIndex);
return this;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
private void checkIndex(int index, int length) {
if (index + length > buffer.writerIndex()) {
throw REPLAY;
}
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public ByteBuf getBytes(int index, ByteBuf dst, int length) {
getBytes(index, dst, dst.writerIndex(), length);
dst.writerIndex(dst.writerIndex() + length);
return this;
}
代码示例来源:origin: com.couchbase.client/core-io
/**
* Creates a new stream which writes data to the specified {@code buffer}.
*/
public ByteBufOutputStream(ByteBuf buffer) {
if (buffer == null) {
throw new NullPointerException("buffer");
}
this.buffer = buffer;
startIndex = buffer.writerIndex();
}
代码示例来源:origin: com.couchbase.client/core-io
private boolean compressInto(ByteBuf compressed) {
byte[] out = compressed.array();
int off = compressed.arrayOffset() + compressed.writerIndex();
int toWrite = compressed.writableBytes();
int numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH);
compressed.writerIndex(compressed.writerIndex() + numBytes);
return numBytes == toWrite;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public ByteBuf readBytes(ByteBuf dst, int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException(String.format(
"length(%d) exceeds dst.writableBytes(%d) where dst is: %s", length, dst.writableBytes(), dst));
}
readBytes(dst, dst.writerIndex(), length);
dst.writerIndex(dst.writerIndex() + length);
return this;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
SSLEngineResult unwrap(SslHandler handler, ByteBuf in, int readerIndex, int len, ByteBuf out)
throws SSLException {
int writerIndex = out.writerIndex();
final SSLEngineResult result = handler.engine.unwrap(toByteBuffer(in, readerIndex, len),
toByteBuffer(out, writerIndex, out.writableBytes()));
out.writerIndex(writerIndex + result.bytesProduced());
return result;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public int indexOf(int fromIndex, int toIndex, byte value) {
if (fromIndex == toIndex) {
return -1;
}
if (Math.max(fromIndex, toIndex) > buffer.writerIndex()) {
throw REPLAY;
}
return buffer.indexOf(fromIndex, toIndex, value);
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public int indexOf(int fromIndex, int toIndex, byte value) {
if (fromIndex == toIndex) {
return -1;
}
if (Math.max(fromIndex, toIndex) > buffer.writerIndex()) {
throw REPLAY;
}
return buffer.indexOf(fromIndex, toIndex, value);
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public int bytesBefore(int length, byte value) {
final int readerIndex = buffer.readerIndex();
return bytesBefore(readerIndex, buffer.writerIndex() - readerIndex, value);
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public int bytesBefore(int length, byte value) {
final int readerIndex = buffer.readerIndex();
return bytesBefore(readerIndex, buffer.writerIndex() - readerIndex, value);
}
代码示例来源:origin: com.couchbase.client/core-io
public static ByteBuf encode(ByteBuf src, boolean breakLines, Base64Dialect dialect) {
if (src == null) {
throw new NullPointerException("src");
}
ByteBuf dest = encode(src, src.readerIndex(), src.readableBytes(), breakLines, dialect);
src.readerIndex(src.writerIndex());
return dest;
}
代码示例来源:origin: com.couchbase.client/core-io
private static void setChunkLength(ByteBuf out, int lengthIdx) {
int chunkLength = out.writerIndex() - lengthIdx - 3;
if (chunkLength >>> 24 != 0) {
throw new CompressionException("compressed data too large: " + chunkLength);
}
out.setMedium(lengthIdx, ByteBufUtil.swapMedium(chunkLength));
}
代码示例来源:origin: couchbase/couchbase-jvm-core
public static ByteBuf decode(ByteBuf src, Base64Dialect dialect) {
if (src == null) {
throw new NullPointerException("src");
}
ByteBuf dest = decode(src, src.readerIndex(), src.readableBytes(), dialect);
src.readerIndex(src.writerIndex());
return dest;
}
代码示例来源:origin: com.couchbase.client/core-io
public ReadOnlyByteBuf(ByteBuf buffer) {
super(buffer.maxCapacity());
if (buffer instanceof ReadOnlyByteBuf || buffer instanceof DuplicatedByteBuf) {
this.buffer = buffer.unwrap();
} else {
this.buffer = buffer;
}
setIndex(buffer.readerIndex(), buffer.writerIndex());
}
代码示例来源:origin: com.couchbase.client/core-io
/**
* Same as {@link Base64#encode(ByteBuf, boolean)} but allows the use of a custom {@link ByteBufAllocator}.
*
* @see Base64#encode(ByteBuf, boolean)
*/
static ByteBuf toBase64(ByteBufAllocator allocator, ByteBuf src) {
ByteBuf dst = Base64.encode(src, src.readerIndex(),
src.readableBytes(), true, Base64Dialect.STANDARD, allocator);
src.readerIndex(src.writerIndex());
return dst;
}
代码示例来源:origin: com.couchbase.client/core-io
public DuplicatedByteBuf(ByteBuf buffer) {
super(buffer.maxCapacity());
if (buffer instanceof DuplicatedByteBuf) {
this.buffer = ((DuplicatedByteBuf) buffer).buffer;
} else {
this.buffer = buffer;
}
setIndex(buffer.readerIndex(), buffer.writerIndex());
markReaderIndex();
markWriterIndex();
}
内容来源于网络,如有侵权,请联系作者删除!