Package cn.sliew.milky.io
Interface DataOutputView
-
- All Superinterfaces:
AutoCloseable,Closeable,DataOutput,Flushable,Serializable
- All Known Implementing Classes:
OutputStreamDataOutputView
public interface DataOutputView extends DataOutput, Closeable, Flushable, Serializable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()voidflush()byte[]getBuffer()default voidwrite(byte[] b)default voidwrite(byte[] b, int off, int len)default voidwriteBoolean(boolean v)Writes a 1 byte boolean.voidwriteBytes(byte[] b)voidwriteBytes(byte[] b, int off, int len)default voidwriteChar(int v)Writes a 2 byte char.default voidwriteDouble(double v)Writes a 8 byte double.default voidwriteFloat(float v)Writes a 4 byte float.default voidwriteInt(int v)Writes a 4 byte int.default voidwriteLong(long i)Writes an 8 byte long.default voidwriteOptionalBoolean(Boolean b)Writes an optionalBoolean.default voidwriteOptionalDouble(Double v)Writes an optionalDouble.default voidwriteOptionalFloat(Float v)Writes an optionalFloat.default voidwriteOptionalInt(Integer integer)Writes an optionalInteger.default voidwriteOptionalLong(Long l)Writes an optionalLong.default voidwriteOptionalVInt(Integer integer)default voidwriteOptionalVLong(Long l)default voidwriteOptionalZLong(Long l)default voidwriteShort(int v)Writes a 2 byte short.default voidwriteVDouble(double value, double precision, boolean optimizePositive)Writes a 1-9 byte double with reduced precision.default voidwriteVFloat(float value, float precision)Writes a 1-5 byte float with reduced precision.default voidwriteVInt(int v)Writes an int in a variable-length format.default voidwriteVLong(long i)Writes a long in a variable-length format.default voidwriteZInt(int v)Writes azig-zag-encodedvariable-lengthinteger.default voidwriteZLong(long i)Writes a long in a variable-length format.-
Methods inherited from interface java.io.DataOutput
write, writeByte, writeBytes, writeChars, writeUTF
-
-
-
-
Field Detail
-
ZERO
static final byte ZERO
- See Also:
- Constant Field Values
-
ONE
static final byte ONE
- See Also:
- Constant Field Values
-
TWO
static final byte TWO
- See Also:
- Constant Field Values
-
-
Method Detail
-
writeBytes
void writeBytes(byte[] b) throws IOException- Throws:
IOException
-
writeBytes
void writeBytes(byte[] b, int off, int len) throws IOException- Throws:
IOException
-
write
default void write(byte[] b) throws IOException- Specified by:
writein interfaceDataOutput- Throws:
IOException
-
write
default void write(byte[] b, int off, int len) throws IOException- Specified by:
writein interfaceDataOutput- Throws:
IOException
-
writeBoolean
default void writeBoolean(boolean v) throws IOExceptionWrites a 1 byte boolean.- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeOptionalBoolean
default void writeOptionalBoolean(Boolean b) throws IOException
Writes an optionalBoolean.- Throws:
IOException
-
writeShort
default void writeShort(int v) throws IOExceptionWrites a 2 byte short.- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
default void writeChar(int v) throws IOExceptionWrites a 2 byte char.- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
default void writeInt(int v) throws IOExceptionWrites a 4 byte int.- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeVInt
default void writeVInt(int v) throws IOExceptionWrites an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers will always use all 5 bytes and are therefore better serialized usingwriteInt(int)orwriteZInt(int)- Throws:
IOException
-
writeZInt
default void writeZInt(int v) throws IOExceptionWrites azig-zag-encodedvariable-lengthinteger. This is typically useful to write small signed ints and is equivalent to callingwriteVInt(BitUtil.zigZagEncode(i)).- Throws:
IOException- See Also:
DataInputView.readZInt()
-
writeOptionalInt
default void writeOptionalInt(Integer integer) throws IOException
Writes an optionalInteger.- Throws:
IOException
-
writeOptionalVInt
default void writeOptionalVInt(Integer integer) throws IOException
- Throws:
IOException
-
writeLong
default void writeLong(long i) throws IOExceptionWrites an 8 byte long.- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeVLong
default void writeVLong(long i) throws IOExceptionWrites a long in a variable-length format. Writes between one and ten bytes. Smaller values take fewer bytes. Negative numbers use ten bytes so preferwriteLong(long)orwriteZLong(long)for negative numbers.- Throws:
IOException
-
writeZLong
default void writeZLong(long i) throws IOExceptionWrites a long in a variable-length format. Writes between one and ten bytes. Values are remapped by sliding the sign bit into the lsb and then encoded as an unsigned number e.g., 0 -;> 0, -1 -;> 1, 1 -;> 2, ..., Long.MIN_VALUE -;> -1, Long.MAX_VALUE -;> -2 Numbers with small absolute value will have a small encoding If the numbers are known to be non-negative, usewriteVLong(long)- Throws:
IOException
-
writeOptionalLong
default void writeOptionalLong(Long l) throws IOException
Writes an optionalLong.- Throws:
IOException
-
writeOptionalVLong
default void writeOptionalVLong(Long l) throws IOException
- Throws:
IOException
-
writeOptionalZLong
default void writeOptionalZLong(Long l) throws IOException
- Throws:
IOException
-
writeFloat
default void writeFloat(float v) throws IOExceptionWrites a 4 byte float.- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeVFloat
default void writeVFloat(float value, float precision) throws IOExceptionWrites a 1-5 byte float with reduced precision. Small positive numbers will be more efficient (1 byte) and small negative numbers will be inefficient (5 bytes).- Throws:
IOException
-
writeVDouble
default void writeVDouble(double value, double precision, boolean optimizePositive) throws IOExceptionWrites a 1-9 byte double with reduced precision. Small positive numbers will be more efficient (1 byte) and small negative numbers will be inefficient (9 bytes).- Throws:
IOException
-
writeOptionalFloat
default void writeOptionalFloat(Float v) throws IOException
Writes an optionalFloat.- Throws:
IOException
-
writeDouble
default void writeDouble(double v) throws IOExceptionWrites a 8 byte double.- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeOptionalDouble
default void writeOptionalDouble(Double v) throws IOException
Writes an optionalDouble.- Throws:
IOException
-
getBuffer
byte[] getBuffer()
-
flush
void flush() throws IOException- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
close
void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-