Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://aoindustries.com/contact
public class StreamableOutput extends DataOutputStream
StreamableInput| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_COMPRESSED_INT_VALUE
The maximum value of int that can be written via
writeCompressedInt(int)
or writeCompressedInt(int, java.io.OutputStream). |
static int |
MIN_COMPRESSED_INT_VALUE
The minimum value of int that can be written via
writeCompressedInt(int)
or writeCompressedInt(int, java.io.OutputStream). |
writtenout| Constructor and Description |
|---|
StreamableOutput(OutputStream out) |
| Modifier and Type | Method and Description |
|---|---|
void |
writeCompressedInt(int i) |
static void |
writeCompressedInt(int i,
OutputStream out) |
void |
writeCompressedUTF(String str) |
void |
writeCompressedUTF(String str,
int slot)
Writes a String to the stream while using prefix compression.
|
void |
writeEnum(Enum<?> e)
Writes an
Enum, represented by its Enum.name(). |
void |
writeIdentifier(Identifier identifier)
Writes an
Identifier. |
void |
writeLongUTF(String str)
Writes a string of any length.
|
void |
writeNullBoolean(Boolean b) |
void |
writeNullByte(Byte b) |
void |
writeNullEnum(Enum<?> e)
|
void |
writeNullIdentifier(Identifier identifier)
Writes a possibly-
null Identifier. |
void |
writeNullInteger(Integer i) |
void |
writeNullLong(Long l) |
void |
writeNullLongUTF(String str)
Writes a string of any length, supporting
null. |
void |
writeNullShort(Short s) |
void |
writeNullSmallIdentifier(SmallIdentifier identifier)
Writes a possibly-
null SmallIdentifier. |
void |
writeNullTimestamp(Timestamp ts)
Writes a possibly-
null Timestamp. |
void |
writeNullUTF(String str) |
void |
writeSmallIdentifier(SmallIdentifier identifier)
Writes a
SmallIdentifier. |
void |
writeTimestamp(Timestamp ts)
Writes a
Timestamp. |
static void |
writeTimestamp(Timestamp ts,
DataOutputStream out)
Writes a
Timestamp, maintaining the full nanosecond precision. |
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFclose, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwritepublic static final int MIN_COMPRESSED_INT_VALUE
writeCompressedInt(int)
or writeCompressedInt(int, java.io.OutputStream).public static final int MAX_COMPRESSED_INT_VALUE
writeCompressedInt(int)
or writeCompressedInt(int, java.io.OutputStream).public StreamableOutput(OutputStream out)
public static void writeCompressedInt(int i,
OutputStream out)
throws IOException
IOExceptionStreamableInput.readCompressedInt()public void writeCompressedInt(int i)
throws IOException
IOExceptionpublic void writeCompressedUTF(String str) throws IOException
IOExceptionpublic void writeCompressedUTF(String str, int slot) throws IOException
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
IOExceptionpublic void writeNullUTF(String str) throws IOException
IOExceptionpublic void writeLongUTF(String str) throws IOException
IOExceptionpublic void writeNullLongUTF(String str) throws IOException
null.IOExceptionpublic void writeNullByte(Byte b) throws IOException
IOExceptionpublic void writeNullShort(Short s) throws IOException
IOExceptionpublic void writeNullInteger(Integer i) throws IOException
IOExceptionpublic void writeNullLong(Long l) throws IOException
IOExceptionpublic void writeEnum(Enum<?> e) throws IOException
Enum, represented by its Enum.name().IOExceptionpublic void writeNullEnum(Enum<?> e) throws IOException
IOExceptionpublic void writeNullBoolean(Boolean b) throws IOException
IOExceptionpublic static void writeTimestamp(Timestamp ts, DataOutputStream out) throws IOException
Timestamp, maintaining the full nanosecond precision.
Time zone offset is not maintained.
The wire protocol is DataOutputStream.writeLong(long) number of seconds followed
by compressed int number of nanoseconds.
This is deliberately compatible with Instant that is part of Java 8.
Once Java 8 is our minimum Java version, many uses of Timestamp will
change to Instant.
IOExceptionpublic void writeTimestamp(Timestamp ts) throws IOException
Timestamp.IOExceptionwriteTimestamp(java.sql.Timestamp, java.io.DataOutputStream)public void writeNullTimestamp(Timestamp ts) throws IOException
null Timestamp.IOExceptionwriteTimestamp(java.sql.Timestamp)public void writeIdentifier(Identifier identifier) throws IOException
Identifier.IOExceptionpublic void writeNullIdentifier(Identifier identifier) throws IOException
null Identifier.IOExceptionpublic void writeSmallIdentifier(SmallIdentifier identifier) throws IOException
SmallIdentifier.IOExceptionpublic void writeNullSmallIdentifier(SmallIdentifier identifier) throws IOException
null SmallIdentifier.IOExceptionCopyright © 2000–2019 AO Industries, Inc.. All rights reserved.