Top Description Fields Constructors Methods
org.eclipse.jgit.lib

public Class ObjectIdSerializer

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH

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

Modifier and TypeField and Description
private static final byte
private static final byte

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ObjectId

Returns:

the object id, or null
read
(InputStream
the input stream
in
)

Read a possibly null ObjectId from the stream.

public static ObjectId

Returns:

the object id; never null
readWithoutMarker
(InputStream
the input stream
in
)

Read a non-null ObjectId from the stream.

public static void
write(OutputStream
the output stream
out
,
AnyObjectId
the object id to serialize; may be null
id
)

Write a possibly null ObjectId to the stream, using markers to differentiate null and non-null instances.

public static void
writeWithoutMarker(OutputStream
the output stream
out
,
AnyObjectId
the object id to serialize; never null
id
)

Write a non-null ObjectId to the stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NON_NULL_MARKERback to summary
private static final byte NON_NULL_MARKER
NULL_MARKERback to summary
private static final byte NULL_MARKER

Constructor Detail

ObjectIdSerializerback to summary
private ObjectIdSerializer()

Method Detail

readback to summary
public static ObjectId read(InputStream in) throws IOException

Read a possibly null ObjectId from the stream. Reads the first byte of the stream, which is expected to be either NON_NULL_MARKER or NULL_MARKER.

Parameters
in:InputStream

the input stream

Returns:ObjectId

the object id, or null

Annotations
@Nullable
Exceptions
IOException:
there was an error reading the stream
readWithoutMarkerback to summary
public static ObjectId readWithoutMarker(InputStream in) throws IOException

Read a non-null ObjectId from the stream.

Parameters
in:InputStream

the input stream

Returns:ObjectId

the object id; never null

Annotations
@NonNull
Exceptions
IOException:
there was an error reading the stream
Since
4.11
writeback to summary
public static void write(OutputStream out, AnyObjectId id) throws IOException

Write a possibly null 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.

Parameters
out:OutputStream

the output stream

id:AnyObjectId

the object id to serialize; may be null

Exceptions
IOException:
the stream writing failed
writeWithoutMarkerback to summary
public static void writeWithoutMarker(OutputStream out, AnyObjectId id) throws IOException

Write a non-null ObjectId to the stream.

Parameters
out:OutputStream

the output stream

id:AnyObjectId

the object id to serialize; never null

Exceptions
IOException:
the stream writing failed
Since
4.11