Package com.aoindustries.io.stream
Class StreamableOutput
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.DataOutputStream
-
- com.aoindustries.io.stream.StreamableOutput
-
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable
public class StreamableOutput extends DataOutputStream
Adds compressed data transfer to DataOutputStream. This class is not thread safe.- Author:
- AO Industries, Inc.
- See Also:
StreamableInput
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_COMPRESSED_INT_VALUEThe maximum value of int that can be written viawriteCompressedInt(int)orwriteCompressedInt(int, java.io.OutputStream).static intMIN_COMPRESSED_INT_VALUEThe minimum value of int that can be written viawriteCompressedInt(int)orwriteCompressedInt(int, java.io.OutputStream).-
Fields inherited from class java.io.DataOutputStream
written
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description StreamableOutput(OutputStream out)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckCompressedInt(int i)Verifies a value is in the acceptable range for a compressed int.voidwriteCompressedInt(int i)static voidwriteCompressedInt(int i, OutputStream out)voidwriteCompressedUTF(String str)voidwriteCompressedUTF(String str, int slot)Writes a String to the stream while using prefix compression.voidwriteEnum(Enum<?> e)Writes anEnum, represented by itsEnum.name().voidwriteLongUTF(String str)Writes a string of any length.voidwriteNullBoolean(Boolean b)voidwriteNullByte(Byte b)voidwriteNullEnum(Enum<?> e)voidwriteNullInteger(Integer i)voidwriteNullLong(Long l)voidwriteNullLongUTF(String str)Writes a string of any length, supportingnull.voidwriteNullShort(Short s)voidwriteNullUTF(String str)-
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Methods inherited from class java.io.FilterOutputStream
close, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.io.DataOutput
write
-
-
-
-
Field Detail
-
MIN_COMPRESSED_INT_VALUE
public static final int MIN_COMPRESSED_INT_VALUE
The minimum value of int that can be written viawriteCompressedInt(int)orwriteCompressedInt(int, java.io.OutputStream).- See Also:
- Constant Field Values
-
MAX_COMPRESSED_INT_VALUE
public static final int MAX_COMPRESSED_INT_VALUE
The maximum value of int that can be written viawriteCompressedInt(int)orwriteCompressedInt(int, java.io.OutputStream).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StreamableOutput
public StreamableOutput(OutputStream out)
-
-
Method Detail
-
checkCompressedInt
public static void checkCompressedInt(int i) throws IOExceptionVerifies a value is in the acceptable range for a compressed int.- Throws:
IOException- See Also:
writeCompressedInt(int),MIN_COMPRESSED_INT_VALUE,MAX_COMPRESSED_INT_VALUE
-
writeCompressedInt
public static void writeCompressedInt(int i, OutputStream out) throws IOException- Throws:
IOException- See Also:
StreamableInput.readCompressedInt()
-
writeCompressedInt
public void writeCompressedInt(int i) throws IOException- Throws:
IOException
-
writeCompressedUTF
public void writeCompressedUTF(String str) throws IOException
- Throws:
IOException
-
writeCompressedUTF
public void writeCompressedUTF(String str, int slot) throws IOException
Writes a String to the stream while using prefix compression.The first byte has these bits: X X X X X X X X | | +-+-+-+-+-+ Slot number (0-63) | +------------ 1 = Suffix UTF follows, 0 = No suffix UTF exists +-------------- 1 = Common length difference follows, 0 = Common length not changed Second, if common length difference is not zero, the common length change follows one less for positive differences because 0 is handled in first byte Third, if suffix UTF follows, writeUTF of all the string after common length- Throws:
IOException
-
writeNullUTF
public void writeNullUTF(String str) throws IOException
- Throws:
IOException
-
writeLongUTF
public void writeLongUTF(String str) throws IOException
Writes a string of any length.- Throws:
IOException
-
writeNullLongUTF
public void writeNullLongUTF(String str) throws IOException
Writes a string of any length, supportingnull.- Throws:
IOException
-
writeNullByte
public void writeNullByte(Byte b) throws IOException
- Throws:
IOException
-
writeNullShort
public void writeNullShort(Short s) throws IOException
- Throws:
IOException
-
writeNullInteger
public void writeNullInteger(Integer i) throws IOException
- Throws:
IOException
-
writeNullLong
public void writeNullLong(Long l) throws IOException
- Throws:
IOException
-
writeEnum
public void writeEnum(Enum<?> e) throws IOException
Writes anEnum, represented by itsEnum.name().- Throws:
IOException
-
writeNullEnum
public void writeNullEnum(Enum<?> e) throws IOException
- Throws:
IOException
-
writeNullBoolean
public void writeNullBoolean(Boolean b) throws IOException
- Throws:
IOException
-
-