Package org.iq80.leveldb.util
Class BasicSliceOutput
java.lang.Object
java.io.OutputStream
org.iq80.leveldb.util.SliceOutput
org.iq80.leveldb.util.BasicSliceOutput
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.voidreset()Resets this stream to the initial position.intsize()Returns thewriterIndexof this buffer.slice()Returns a slice of this buffer's readable bytes.Converts this buffer's readable bytes into a NIO buffer.toString()Decodes this buffer's readable bytes into a string with the specified character set name.intReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).voidwriteByte(int value) Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.voidwriteBytes(byte[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=source.length).voidwriteBytes(byte[] source, int sourceIndex, int length) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).intwriteBytes(InputStream in, int length) Transfers the content of the specified stream to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(ByteBuffer source) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.intwriteBytes(FileChannel in, int position, int length) intwriteBytes(ScatteringByteChannel in, int length) Transfers the content of the specified channel to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(Slice source) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(SliceInput source, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteBytes(Slice source, int sourceIndex, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteShort(int value) Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.voidwriteZero(int length) Fills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.Methods inherited from class org.iq80.leveldb.util.SliceOutput
write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeUTFMethods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Field Details
-
slice
-
size
private int size
-
-
Constructor Details
-
BasicSliceOutput
-
-
Method Details
-
reset
public void reset()Description copied from class:SliceOutputResets this stream to the initial position.- Specified by:
resetin classSliceOutput
-
size
public int size()Description copied from class:SliceOutputReturns thewriterIndexof this buffer.- Specified by:
sizein classSliceOutput
-
isWritable
public boolean isWritable()Description copied from class:SliceOutputReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.- Specified by:
isWritablein classSliceOutput
-
writableBytes
public int writableBytes()Description copied from class:SliceOutputReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).- Specified by:
writableBytesin classSliceOutput
-
writeByte
public void writeByte(int value) Description copied from class:SliceOutputSets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer. The 24 high-order bits of the specified value are ignored.- Specified by:
writeBytein interfaceDataOutput- Specified by:
writeBytein classSliceOutput
-
writeShort
public void writeShort(int value) Description copied from class:SliceOutputSets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored.- Specified by:
writeShortin interfaceDataOutput- Specified by:
writeShortin classSliceOutput
-
writeInt
public void writeInt(int value) Description copied from class:SliceOutputSets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Specified by:
writeIntin interfaceDataOutput- Specified by:
writeIntin classSliceOutput
-
writeLong
public void writeLong(long value) Description copied from class:SliceOutputSets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Specified by:
writeLongin interfaceDataOutput- Specified by:
writeLongin classSliceOutput
-
writeBytes
public void writeBytes(byte[] source, int sourceIndex, int length) Description copied from class:SliceOutputTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).- Specified by:
writeBytesin classSliceOutput- Parameters:
sourceIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
public void writeBytes(byte[] source) Description copied from class:SliceOutputTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=source.length).- Specified by:
writeBytesin classSliceOutput
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes. This method is basically same withSliceOutput.writeBytes(Slice, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileSliceOutput.writeBytes(Slice, int, int)does not.- Specified by:
writeBytesin classSliceOutput
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). This method is basically same withSliceOutput.writeBytes(Slice, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes (=length) whileSliceOutput.writeBytes(Slice, int, int)does not.- Specified by:
writeBytesin classSliceOutput- Parameters:
length- the number of bytes to transfer
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).- Specified by:
writeBytesin classSliceOutput- Parameters:
sourceIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.- Specified by:
writeBytesin classSliceOutput
-
writeBytes
Description copied from class:SliceOutputTransfers the content of the specified stream to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.- Specified by:
writeBytesin classSliceOutput- 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
Description copied from class:SliceOutputTransfers the content of the specified channel to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.- Specified by:
writeBytesin classSliceOutput- 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
- Specified by:
writeBytesin classSliceOutput- Throws:
IOException
-
writeZero
public void writeZero(int length) Description copied from class:SliceOutputFills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.- Specified by:
writeZeroin classSliceOutput- Parameters:
length- the number of NULs to write to the buffer
-
slice
Description copied from class:SliceOutputReturns 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 tobuf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
slicein classSliceOutput
-
toByteBuffer
Description copied from class:SliceOutputConverts 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 tobuf.toByteBuffer(buf.readerIndex(), buf.readableBytes()). This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
toByteBufferin classSliceOutput
-
toString
-
toString
Description copied from class:SliceOutputDecodes this buffer's readable bytes into a string with the specified character set name. This method is identical tobuf.toString(buf.readerIndex(), buf.readableBytes(), charsetName). This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
toStringin classSliceOutput
-