Package org.eclipse.jgit.lib
Class ObjectIdSerializer
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectIdSerializer
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectIdread(InputStream in)Read a possibly nullObjectIdfrom the stream.static ObjectIdreadWithoutMarker(InputStream in)Read a non-nullObjectIdfrom the stream.static voidwrite(OutputStream out, AnyObjectId id)Write a possibly nullObjectIdto the stream, using markers to differentiate null and non-null instances.static voidwriteWithoutMarker(OutputStream out, AnyObjectId id)Write a non-nullObjectIdto the stream.
-
-
-
Method Detail
-
write
public static void write(OutputStream out, @Nullable AnyObjectId id) throws IOException
Write a possibly nullObjectIdto the stream, using markers to differentiate null and non-null instances.If the id is non-null, writes a
NON_NULL_MARKERfollowed by the id's words. If it is null, writes aNULL_MARKERand nothing else.- Parameters:
out- the output streamid- the object id to serialize; may be null- Throws:
IOException- the stream writing failed
-
writeWithoutMarker
public static void writeWithoutMarker(OutputStream out, @NonNull AnyObjectId id) throws IOException
Write a non-nullObjectIdto the stream.- Parameters:
out- the output streamid- the object id to serialize; never null- Throws:
IOException- the stream writing failed- Since:
- 4.11
-
read
@Nullable public static ObjectId read(InputStream in) throws IOException
Read a possibly nullObjectIdfrom the stream. Reads the first byte of the stream, which is expected to be eitherNON_NULL_MARKERorNULL_MARKER.- Parameters:
in- the input stream- Returns:
- the object id, or null
- Throws:
IOException- there was an error reading the stream
-
readWithoutMarker
@NonNull public static ObjectId readWithoutMarker(InputStream in) throws IOException
Read a non-nullObjectIdfrom 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
-
-