congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.springframework.core.io.buffer
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.core.io.buffer

Best Java code snippets using org.springframework.core.io.buffer (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

private DataBuffer generateBoundaryLine(byte[] boundary) {
  DataBuffer buffer = this.bufferFactory.allocateBuffer(boundary.length + 4);
  buffer.write((byte)'-');
  buffer.write((byte)'-');
  buffer.write(boundary);
  buffer.write((byte)'\r');
  buffer.write((byte)'\n');
  return buffer;
}
origin: spring-projects/spring-framework

@Override
public int read() {
  return available() > 0 ? DefaultDataBuffer.this.read() & 0xFF : -1;
}
origin: spring-projects/spring-framework

/**
 * Release the payload {@code DataBuffer} which is useful on runtimes
 * (e.g. Netty) with pooled buffers such as Netty. A shortcut for:
 * <pre>
 * DataBuffer payload = message.getPayload();
 * DataBufferUtils.release(payload);
 * </pre>
 * @see DataBufferUtils#release(DataBuffer)
 */
public void release() {
  DataBufferUtils.release(this.payload);
}
origin: spring-projects/spring-framework

  private Consumer<DataBuffer> expectDataBuffer(byte[] expected) {
    return actual -> {
      byte[] actualBytes = new byte[actual.readableByteCount()];
      actual.read(actualBytes);
      assertArrayEquals(expected, actualBytes);

      DataBufferUtils.release(actual);
    };
  }
}
origin: spring-projects/spring-framework

@Override
public DataBuffer allocateBuffer(int initialCapacity) {
  return allocateBufferInternal(this.delegate.allocateBuffer(initialCapacity));
}
origin: spring-projects/spring-framework

private DataBuffer stringBuffer(String value) {
  byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
  DataBuffer buffer = this.bufferFactory.allocateBuffer(bytes.length);
  buffer.write(bytes);
  return buffer;
}
origin: spring-projects/spring-framework

/**
 * Creates a new {@code LeakAwareDataBufferFactory} by wrapping a
 * {@link DefaultDataBufferFactory}.
 */
public LeakAwareDataBufferFactory() {
  this(new DefaultDataBufferFactory());
}
origin: spring-projects/spring-framework

@Override
public DataBuffer ensureCapacity(int length) {
  if (length > writableByteCount()) {
    int newCapacity = calculateCapacity(this.writePosition + length);
    capacity(newCapacity);
  }
  return this;
}
origin: spring-projects/spring-framework

  @Override
  public void write(byte[] bytes, int off, int len) throws IOException {
    DefaultDataBuffer.this.write(bytes, off, len);
  }
}
origin: spring-projects/spring-framework

@Override
public DataBuffer join(List<? extends DataBuffer> dataBuffers) {
  return new LeakAwareDataBuffer(this.delegate.join(dataBuffers), this);
}
origin: spring-projects/spring-framework

/**
 * Obtain a {@code AsynchronousFileChannel} from the given supplier, and read it into a
 * {@code Flux} of {@code DataBuffer}s. Closes the channel when the flux is terminated.
 * @param channelSupplier the supplier for the channel to read from
 * @param dataBufferFactory the factory to create data buffers with
 * @param bufferSize the maximum size of the data buffers
 * @return a flux of data buffers read from the given channel
 */
public static Flux<DataBuffer> readAsynchronousFileChannel(
    Callable<AsynchronousFileChannel> channelSupplier, DataBufferFactory dataBufferFactory, int bufferSize) {
  return readAsynchronousFileChannel(channelSupplier, 0, dataBufferFactory, bufferSize);
}
origin: spring-projects/spring-framework

@Override
public DefaultDataBuffer writePosition(int writePosition) {
  assertIndex(writePosition >= this.readPosition, "'writePosition' %d must be >= %d",
      writePosition, this.readPosition);
  assertIndex(writePosition <= this.capacity, "'writePosition' %d must be <= %d",
      writePosition, this.capacity);
  this.writePosition = writePosition;
  return this;
}
origin: spring-projects/spring-framework

/**
 * Wrap the given Netty {@link ByteBuf} in a {@code NettyDataBuffer}.
 * @param byteBuf the Netty byte buffer to wrap
 * @return the wrapped buffer
 */
public NettyDataBuffer wrap(ByteBuf byteBuf) {
  return new NettyDataBuffer(byteBuf, this);
}
origin: spring-projects/spring-framework

private DataBuffer generateNewLine() {
  DataBuffer buffer = this.bufferFactory.allocateBuffer(2);
  buffer.write((byte)'\r');
  buffer.write((byte)'\n');
  return buffer;
}
origin: spring-projects/spring-framework

  @Override
  protected void discardData(DataBuffer dataBuffer) {
    DataBufferUtils.release(dataBuffer);
  }
}
origin: spring-projects/spring-framework

@Override
public DataBuffer allocateBuffer() {
  return allocateBufferInternal(this.delegate.allocateBuffer());
}
origin: spring-projects/spring-framework

private void checkIndex(int index, int length) {
  assertIndex(index >= 0, "index %d must be >= 0", index);
  assertIndex(length >= 0, "length %d must be >= 0", index);
  assertIndex(index <= this.capacity, "index %d must be <= %d", index, this.capacity);
  assertIndex(length <= this.capacity, "length %d must be <= %d", index, this.capacity);
}
origin: spring-projects/spring-framework

private DataBuffer generateLastLine(byte[] boundary) {
  DataBuffer buffer = this.bufferFactory.allocateBuffer(boundary.length + 6);
  buffer.write((byte)'-');
  buffer.write((byte)'-');
  buffer.write(boundary);
  buffer.write((byte)'-');
  buffer.write((byte)'-');
  buffer.write((byte)'\r');
  buffer.write((byte)'\n');
  return buffer;
}
origin: spring-projects/spring-framework

  @Override
  protected void discardData(DataBuffer dataBuffer) {
    DataBufferUtils.release(dataBuffer);
  }
}
origin: spring-projects/spring-framework

protected DataBuffer byteBuffer(byte[] value) {
  DataBuffer buffer = this.bufferFactory.allocateBuffer(value.length);
  buffer.write(value);
  return buffer;
}
org.springframework.core.io.buffer

Most used classes

  • DataBuffer
    Basic abstraction over byte buffers. DataBuffers has a separate #readPosition() and #writePosition()
  • DataBufferFactory
    A factory for DataBuffer, allowing for allocation and wrapping of data buffers.
  • DataBufferUtils
    Utility class for working with DataBuffer.
  • DefaultDataBufferFactory
    Default implementation of the DataBufferFactory interface. Allows for specification of the default i
  • NettyDataBufferFactory
    Implementation of the DataBufferFactory interface based on a Netty ByteBufAllocator.
  • DefaultDataBuffer,
  • PooledDataBuffer,
  • DataBufferTestUtils,
  • DataBufferUtils$AsynchronousFileChannelReadCompletionHandler,
  • DataBufferUtils$AsynchronousFileChannelWriteCompletionHandler,
  • DataBufferUtils$ReadableByteChannelGenerator,
  • DataBufferUtils$WritableByteChannelSubscriber,
  • DefaultDataBuffer$DefaultDataBufferInputStream,
  • DefaultDataBuffer$DefaultDataBufferOutputStream,
  • DefaultDataBuffer$SlicedDefaultDataBuffer,
  • LeakAwareDataBufferFactory,
  • AbstractDataBufferAllocatingTestCase,
  • DataBufferTests,
  • DataBufferUtilsTests
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now