@Override public DefaultDataBuffer write(byte b) { ensureCapacity(1); int pos = this.writePosition; this.byteBuffer.put(pos, b); this.writePosition = pos + 1; return this; }
@Override public DefaultDataBuffer write(ByteBuffer... buffers) { if (!ObjectUtils.isEmpty(buffers)) { int capacity = Arrays.stream(buffers).mapToInt(ByteBuffer::remaining).sum(); ensureCapacity(capacity); Arrays.stream(buffers).forEach(this::write); } return this; }
@Override public DefaultDataBuffer write(byte b) { ensureCapacity(1); int pos = this.writePosition; this.byteBuffer.put(pos, b); this.writePosition = pos + 1; return this; }
@Override public DefaultDataBuffer write(byte[] source, int offset, int length) { Assert.notNull(source, "Byte array must not be null"); ensureCapacity(length); ByteBuffer tmp = this.byteBuffer.duplicate(); int limit = this.writePosition + length; ((Buffer) tmp).clear().position(this.writePosition).limit(limit); tmp.put(source, offset, length); this.writePosition += length; return this; }
@Override public DefaultDataBuffer write(ByteBuffer... buffers) { if (!ObjectUtils.isEmpty(buffers)) { int capacity = Arrays.stream(buffers).mapToInt(ByteBuffer::remaining).sum(); ensureCapacity(capacity); Arrays.stream(buffers).forEach(this::write); } return this; }
@Override public DefaultDataBuffer write(byte[] source, int offset, int length) { Assert.notNull(source, "Byte array must not be null"); ensureCapacity(length); ByteBuffer tmp = this.byteBuffer.duplicate(); int limit = this.writePosition + length; ((Buffer) tmp).clear().position(this.writePosition).limit(limit); tmp.put(source, offset, length); this.writePosition += length; return this; }
@Override public DefaultDataBuffer write(byte b) { ensureCapacity(1); int pos = this.writePosition; this.byteBuffer.put(pos, b); this.writePosition = pos + 1; return this; }
@Override public DefaultDataBuffer write(byte b) { ensureCapacity(1); int pos = this.writePosition; this.byteBuffer.put(pos, b); this.writePosition = pos + 1; return this; }
@Override public DefaultDataBuffer write(ByteBuffer... byteBuffers) { Assert.notEmpty(byteBuffers, "'byteBuffers' must not be empty"); int capacity = Arrays.stream(byteBuffers).mapToInt(ByteBuffer::remaining).sum(); ensureCapacity(capacity); Arrays.stream(byteBuffers).forEach(this::write); return this; }
@Override public DefaultDataBuffer write(ByteBuffer... buffers) { if (!ObjectUtils.isEmpty(buffers)) { int capacity = Arrays.stream(buffers).mapToInt(ByteBuffer::remaining).sum(); ensureCapacity(capacity); Arrays.stream(buffers).forEach(this::write); } return this; }
@Override public DefaultDataBuffer write(byte[] source, int offset, int length) { Assert.notNull(source, "'source' must not be null"); ensureCapacity(length); ByteBuffer tmp = this.byteBuffer.duplicate(); int limit = this.writePosition + length; ((Buffer) tmp).clear().position(this.writePosition).limit(limit); tmp.put(source, offset, length); this.writePosition += length; return this; }
@Override public DefaultDataBuffer write(byte[] source, int offset, int length) { Assert.notNull(source, "Byte array must not be null"); ensureCapacity(length); ByteBuffer tmp = this.byteBuffer.duplicate(); int limit = this.writePosition + length; ((Buffer) tmp).clear().position(this.writePosition).limit(limit); tmp.put(source, offset, length); this.writePosition += length; return this; }