Package org.jboss.jandex
Class PackedDataOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
org.jboss.jandex.PackedDataOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
An output stream that can pack integers into as few bytes as possible.
PackedDataOutputStream
Thread-Safety
This class is not thread-safe can not be shared between threads.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
Fields inherited from class java.io.DataOutputStream
written
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
writePackedU32
(int i) Writes an unsigned integer in as few bytes as possible.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 Details
-
MAX_1BYTE
static final int MAX_1BYTE- See Also:
-
MAX_2BYTE
static final int MAX_2BYTE- See Also:
-
MAX_3BYTE
static final int MAX_3BYTE- See Also:
-
MAX_4BYTE
static final int MAX_4BYTE- See Also:
-
-
Constructor Details
-
PackedDataOutputStream
-
-
Method Details
-
writePackedU32
Writes an unsigned integer in as few bytes as possible. Every byte uses the first bit as a control bit to signal when there are additional bytes to be read on the receiving end. The remaining seven bits are data. Depending on the size of the number one to five bytes may be written. The bytes are written in network-order (big endian)Note that a signed integer can still be used, but due to two's compliment, all negative values will be written as five bytes
- Parameters:
i
- the integer to pack and write- Throws:
IOException
- if any i/o error occurs
-