Modifier and Type | Field and Description |
---|---|
private static byte |
NON_NULL_MARKER |
private static byte |
NULL_MARKER |
Modifier | Constructor and Description |
---|---|
private |
ObjectIdSerializer() |
Modifier and Type | Method and Description |
---|---|
static ObjectId |
read(java.io.InputStream in)
Read a possibly null
ObjectId from the stream. |
static ObjectId |
readWithoutMarker(java.io.InputStream in)
Read a non-null
ObjectId from the stream. |
static void |
write(java.io.OutputStream out,
AnyObjectId id)
Write a possibly null
ObjectId to the stream, using markers to
differentiate null and non-null instances. |
static void |
writeWithoutMarker(java.io.OutputStream out,
AnyObjectId id)
Write a non-null
ObjectId to the stream. |
private static final byte NULL_MARKER
private static final byte NON_NULL_MARKER
public static void write(java.io.OutputStream out, @Nullable AnyObjectId id) throws java.io.IOException
ObjectId
to the stream, using markers to
differentiate null and non-null instances.
If the id is non-null, writes a NON_NULL_MARKER
followed by the
id's words. If it is null, writes a NULL_MARKER
and nothing
else.
out
- the output streamid
- the object id to serialize; may be nulljava.io.IOException
- the stream writing failedpublic static void writeWithoutMarker(java.io.OutputStream out, @NonNull AnyObjectId id) throws java.io.IOException
ObjectId
to the stream.out
- the output streamid
- the object id to serialize; never nulljava.io.IOException
- the stream writing failed@Nullable public static ObjectId read(java.io.InputStream in) throws java.io.IOException
ObjectId
from the stream.
Reads the first byte of the stream, which is expected to be either
NON_NULL_MARKER
or NULL_MARKER
.in
- the input streamjava.io.IOException
- there was an error reading the stream@NonNull public static ObjectId readWithoutMarker(java.io.InputStream in) throws java.io.IOException
ObjectId
from the stream.in
- the input streamjava.io.IOException
- there was an error reading the stream