Package org.eclipse.jgit.lib
Class ObjectIdSerializer
java.lang.Object
org.eclipse.jgit.lib.ObjectIdSerializer
Helper to serialize
ObjectId
instances. ObjectId
is already
serializable, but this class provides methods to handle null and non-null
instances.- Since:
- 4.11
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte
private static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectId
read
(InputStream in) Read a possibly nullObjectId
from the stream.static ObjectId
Read a non-nullObjectId
from the stream.static void
write
(OutputStream out, AnyObjectId id) Write a possibly nullObjectId
to the stream, using markers to differentiate null and non-null instances.static void
writeWithoutMarker
(OutputStream out, AnyObjectId id) Write a non-nullObjectId
to the stream.
-
Field Details
-
NULL_MARKER
private static final byte NULL_MARKER- See Also:
-
NON_NULL_MARKER
private static final byte NON_NULL_MARKER- See Also:
-
-
Constructor Details
-
ObjectIdSerializer
private ObjectIdSerializer()
-
-
Method Details
-
write
Write a possibly nullObjectId
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 aNULL_MARKER
and nothing else.- Parameters:
out
- the output streamid
- the object id to serialize; may be null- Throws:
IOException
- the stream writing failed
-
writeWithoutMarker
Write a non-nullObjectId
to the stream.- Parameters:
out
- the output streamid
- the object id to serialize; never null- Throws:
IOException
- the stream writing failed- Since:
- 4.11
-
read
Read a possibly nullObjectId
from the stream. Reads the first byte of the stream, which is expected to be eitherNON_NULL_MARKER
orNULL_MARKER
.- Parameters:
in
- the input stream- Returns:
- the object id, or null
- Throws:
IOException
- there was an error reading the stream
-
readWithoutMarker
Read a non-nullObjectId
from the stream.- Parameters:
in
- the input stream- Returns:
- the object id; never null
- Throws:
IOException
- there was an error reading the stream- Since:
- 4.11
-