Class BasicSliceOutput

All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

public class BasicSliceOutput extends SliceOutput
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private final Slice
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    void
    Resets this stream to the initial position.
    int
    Returns the writerIndex of this buffer.
    Returns a slice of this buffer's readable bytes.
    Converts this buffer's readable bytes into a NIO buffer.
     
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.
    int
    Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    void
    writeByte(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    void
    writeBytes(byte[] source)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
    void
    writeBytes(byte[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    int
    writeBytes(InputStream in, int length)
    Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    void
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer's position reaches its limit, and increases the writerIndex by the number of the transferred bytes.
    int
    writeBytes(FileChannel in, int position, int length)
     
    int
    Transfers the content of the specified channel to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    void
    writeBytes(Slice source)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes.
    void
    writeBytes(SliceInput source, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeBytes(Slice source, int sourceIndex, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeInt(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeLong(long value)
    Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeShort(int value)
    Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
    void
    writeZero(int length)
    Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.

    Methods inherited from class org.iq80.leveldb.util.SliceOutput

    write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeUTF

    Methods inherited from class java.io.OutputStream

    close, flush, nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • slice

      private final Slice slice
    • size

      private int size
  • Constructor Details

    • BasicSliceOutput

      protected BasicSliceOutput(Slice slice)
  • Method Details

    • reset

      public void reset()
      Description copied from class: SliceOutput
      Resets this stream to the initial position.
      Specified by:
      reset in class SliceOutput
    • size

      public int size()
      Description copied from class: SliceOutput
      Returns the writerIndex of this buffer.
      Specified by:
      size in class SliceOutput
    • isWritable

      public boolean isWritable()
      Description copied from class: SliceOutput
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      Specified by:
      isWritable in class SliceOutput
    • writableBytes

      public int writableBytes()
      Description copied from class: SliceOutput
      Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
      Specified by:
      writableBytes in class SliceOutput
    • writeByte

      public void writeByte(int value)
      Description copied from class: SliceOutput
      Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer. The 24 high-order bits of the specified value are ignored.
      Specified by:
      writeByte in interface DataOutput
      Specified by:
      writeByte in class SliceOutput
    • writeShort

      public void writeShort(int value)
      Description copied from class: SliceOutput
      Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer. The 16 high-order bits of the specified value are ignored.
      Specified by:
      writeShort in interface DataOutput
      Specified by:
      writeShort in class SliceOutput
    • writeInt

      public void writeInt(int value)
      Description copied from class: SliceOutput
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Specified by:
      writeInt in interface DataOutput
      Specified by:
      writeInt in class SliceOutput
    • writeLong

      public void writeLong(long value)
      Description copied from class: SliceOutput
      Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Specified by:
      writeLong in interface DataOutput
      Specified by:
      writeLong in class SliceOutput
    • writeBytes

      public void writeBytes(byte[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      Parameters:
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(byte[] source)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(Slice source)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with SliceOutput.writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while SliceOutput.writeBytes(Slice, int, int) does not.
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(SliceInput source, int length)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length). This method is basically same with SliceOutput.writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes (= length) while SliceOutput.writeBytes(Slice, int, int) does not.
      Specified by:
      writeBytes in class SliceOutput
      Parameters:
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(Slice source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      Parameters:
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(ByteBuffer source)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer's position reaches its limit, and increases the writerIndex by the number of the transferred bytes.
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public int writeBytes(InputStream in, int length) throws IOException
      Description copied from class: SliceOutput
      Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
      Specified by:
      writeBytes in class SliceOutput
      Parameters:
      length - the number of bytes to transfer
      Returns:
      the actual number of bytes read in from the specified stream
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • writeBytes

      public int writeBytes(ScatteringByteChannel in, int length) throws IOException
      Description copied from class: SliceOutput
      Transfers the content of the specified channel to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
      Specified by:
      writeBytes in class SliceOutput
      Parameters:
      length - the maximum number of bytes to transfer
      Returns:
      the actual number of bytes read in from the specified channel
      Throws:
      IOException - if the specified channel threw an exception during I/O
    • writeBytes

      public int writeBytes(FileChannel in, int position, int length) throws IOException
      Specified by:
      writeBytes in class SliceOutput
      Throws:
      IOException
    • writeZero

      public void writeZero(int length)
      Description copied from class: SliceOutput
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
      Specified by:
      writeZero in class SliceOutput
      Parameters:
      length - the number of NULs to write to the buffer
    • slice

      public Slice slice()
      Description copied from class: SliceOutput
      Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      slice in class SliceOutput
    • toByteBuffer

      public ByteBuffer toByteBuffer()
      Description copied from class: SliceOutput
      Converts this buffer's readable bytes into a NIO buffer. The returned buffer might or might not share the content with this buffer, while they have separate indexes and marks. This method is identical to buf.toByteBuffer(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      toByteBuffer in class SliceOutput
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(Charset charset)
      Description copied from class: SliceOutput
      Decodes this buffer's readable bytes into a string with the specified character set name. This method is identical to buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      toString in class SliceOutput