Package org.eclipse.jgit.lib
Class ObjectIdSerializer
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectIdSerializer
-
-
Field Summary
Fields Modifier and Type Field Description private static byte
NON_NULL_MARKER
private static byte
NULL_MARKER
-
Constructor Summary
Constructors Modifier Constructor Description private
ObjectIdSerializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectId
read(java.io.InputStream in)
Read a possibly nullObjectId
from the stream.static ObjectId
readWithoutMarker(java.io.InputStream in)
Read a non-nullObjectId
from the stream.static void
write(java.io.OutputStream out, AnyObjectId id)
Write a possibly nullObjectId
to the stream, using markers to differentiate null and non-null instances.static void
writeWithoutMarker(java.io.OutputStream out, AnyObjectId id)
Write a non-nullObjectId
to the stream.
-
-
-
Field Detail
-
NULL_MARKER
private static final byte NULL_MARKER
- See Also:
- Constant Field Values
-
NON_NULL_MARKER
private static final byte NON_NULL_MARKER
- See Also:
- Constant Field Values
-
-
Method Detail
-
write
public static void write(java.io.OutputStream out, @Nullable AnyObjectId id) throws java.io.IOException
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:
java.io.IOException
- the stream writing failed
-
writeWithoutMarker
public static void writeWithoutMarker(java.io.OutputStream out, @NonNull AnyObjectId id) throws java.io.IOException
Write a non-nullObjectId
to the stream.- Parameters:
out
- the output streamid
- the object id to serialize; never null- Throws:
java.io.IOException
- the stream writing failed- Since:
- 4.11
-
read
@Nullable public static ObjectId read(java.io.InputStream in) throws java.io.IOException
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:
java.io.IOException
- there was an error reading the stream
-
readWithoutMarker
@NonNull public static ObjectId readWithoutMarker(java.io.InputStream in) throws java.io.IOException
Read a non-nullObjectId
from the stream.- Parameters:
in
- the input stream- Returns:
- the object id; never null
- Throws:
java.io.IOException
- there was an error reading the stream- Since:
- 4.11
-
-