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

public Class ObjectId

extends AnyObjectId
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
org.eclipse.jgit.lib.ObjectIdOwnerMap.Entry, org.eclipse.jgit.notes.NonNoteEntry, org.eclipse.jgit.notes.Note, org.eclipse.jgit.internal.storage.dfs.DfsPackCompactor.ObjectIdWithOffset, org.eclipse.jgit.internal.storage.file.PackBitmapIndexRemapper.Entry, org.eclipse.jgit.internal.storage.pack.BitmapCommit
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.nio.ByteBuffer, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.errors.InvalidObjectIdException, org.eclipse.jgit.util.NB, .RawParseUtils

A SHA-1 abstraction.

Field Summary

Modifier and TypeField and Description
private static final long
private static final ObjectId
private static final String
Inherited from org.eclipse.jgit.lib.AnyObjectId:
w1w2w3w4w5

Constructor Summary

AccessConstructor and Description
public
ObjectId(int
an int
new_1
,
int
an int
new_2
,
int
an int
new_3
,
int
an int
new_4
,
int
an int
new_5
)

Construct an ObjectId from 160 bits provided in 5 words.

protected
ObjectId(AnyObjectId
another already parsed ObjectId to copy the value out of.
src
)

Initialize this instance by copying another existing ObjectId.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the two identifiers are the same.
equals
(final byte[]
the first buffer to compare against. Must have at least 20 bytes from position fi through the end of the buffer.
firstBuffer
,
final int
first offset within firstBuffer to begin testing.
fi
,
final byte[]
the second buffer to compare against. Must have at least 20 bytes from position si through the end of the buffer.
secondBuffer
,
final int
first offset within secondBuffer to begin testing.
si
)

Compare two object identifier byte sequences for equality.

private static final ObjectId
fromHexString(byte[] bs, int p)

public static final ObjectId

Returns:

the converted object id.
fromRaw
(byte[]
the raw byte buffer to read from. At least 20 bytes must be available within this byte array.
bs
)

Convert an ObjectId from raw binary representation.

public static final ObjectId

Returns:

the converted object id.
fromRaw
(byte[]
the raw byte buffer to read from. At least 20 bytes after p must be available within this byte array.
bs
,
int
position to read the first byte of data from.
p
)

Convert an ObjectId from raw binary representation.

public static final ObjectId

Returns:

the converted object id.
fromRaw
(ByteBuffer
a bytebuffer with the objectid encoded as 5 consecutive ints. This is the reverse of ObjectId#copyRawTo(ByteBuffer)
bb
)

Convert an ObjectId from raw binary representation

public static final ObjectId

Returns:

the converted object id.
fromRaw
(int[]
the raw integers buffer to read from. At least 5 integers must be available within this int array.
is
)

Convert an ObjectId from raw binary representation.

public static final ObjectId

Returns:

the converted object id.
fromRaw
(int[]
the raw integers buffer to read from. At least 5 integers after p must be available within this int array.
is
,
int
position to read the first integer of data from.
p
)

Convert an ObjectId from raw binary representation.

public static final ObjectId

Returns:

the converted object id.
fromString
(byte[]
the US-ASCII buffer to read from. At least 40 bytes after offset must be available within this byte array.
buf
,
int
position to read the first character from.
offset
)

Convert an ObjectId from hex characters (US-ASCII).

public static ObjectId

Returns:

the converted object id.
fromString
(String
the string to read from. Must be 40 characters long.
str
)

Convert an ObjectId from hex characters.

public static final boolean

Returns:

true if the string can converted into an ObjectId.
isId
(String
the string to test.
id
)

Test a string of characters to verify it is a hex format.

private void
public ObjectId
toObjectId()

Implements abstract org.eclipse.jgit.lib.AnyObjectId.toObjectId.

Obtain an immutable copy of this current object name value.

public static final String

Returns:

the hex string conversion of this id's content.
toString
(ObjectId
the id to convert. May be null.
i
)

Convert an ObjectId into a hex string representation.

private void
public static final ObjectId

Returns:

the all-null ObjectId, often used to stand-in for no object.
zeroId
()

Get the special all-null ObjectId.

Inherited from org.eclipse.jgit.lib.AnyObjectId:
abbreviatecompareTocompareTocompareTocopycopyRawTocopyRawTocopyRawTocopyRawTocopyTocopyTocopyTocopyTocopyTocopyToequalsequalsformatHexChargetBytegetFirstBytegetNamehashCodeisEqualnamestartsWithtoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
ZEROIDback to summary
private static final ObjectId ZEROID
ZEROID_STRback to summary
private static final String ZEROID_STR

Constructor Detail

ObjectIdback to summary
public ObjectId(int new_1, int new_2, int new_3, int new_4, int new_5)

Construct an ObjectId from 160 bits provided in 5 words.

Parameters
new_1:int

an int

new_2:int

an int

new_3:int

an int

new_4:int

an int

new_5:int

an int

Since
4.7
ObjectIdback to summary
protected ObjectId(AnyObjectId src)

Initialize this instance by copying another existing ObjectId.

This constructor is mostly useful for subclasses who want to extend an ObjectId with more properties, but initialize from an existing ObjectId instance acquired by other means.

Parameters
src:AnyObjectId

another already parsed ObjectId to copy the value out of.

Method Detail

equalsback to summary
public static boolean equals(final byte[] firstBuffer, final int fi, final byte[] secondBuffer, final int si)

Compare two object identifier byte sequences for equality.

Parameters
firstBuffer:byte[]

the first buffer to compare against. Must have at least 20 bytes from position fi through the end of the buffer.

fi:int

first offset within firstBuffer to begin testing.

secondBuffer:byte[]

the second buffer to compare against. Must have at least 20 bytes from position si through the end of the buffer.

si:int

first offset within secondBuffer to begin testing.

Returns:boolean

true if the two identifiers are the same.

fromHexStringback to summary
private static final ObjectId fromHexString(byte[] bs, int p)
fromRawback to summary
public static final ObjectId fromRaw(byte[] bs)

Convert an ObjectId from raw binary representation.

Parameters
bs:byte[]

the raw byte buffer to read from. At least 20 bytes must be available within this byte array.

Returns:ObjectId

the converted object id.

fromRawback to summary
public static final ObjectId fromRaw(byte[] bs, int p)

Convert an ObjectId from raw binary representation.

Parameters
bs:byte[]

the raw byte buffer to read from. At least 20 bytes after p must be available within this byte array.

p:int

position to read the first byte of data from.

Returns:ObjectId

the converted object id.

fromRawback to summary
public static final ObjectId fromRaw(ByteBuffer bb)

Convert an ObjectId from raw binary representation

Parameters
bb:ByteBuffer

a bytebuffer with the objectid encoded as 5 consecutive ints. This is the reverse of ObjectId#copyRawTo(ByteBuffer)

Returns:ObjectId

the converted object id.

Since
7.0
fromRawback to summary
public static final ObjectId fromRaw(int[] is)

Convert an ObjectId from raw binary representation.

Parameters
is:int[]

the raw integers buffer to read from. At least 5 integers must be available within this int array.

Returns:ObjectId

the converted object id.

fromRawback to summary
public static final ObjectId fromRaw(int[] is, int p)

Convert an ObjectId from raw binary representation.

Parameters
is:int[]

the raw integers buffer to read from. At least 5 integers after p must be available within this int array.

p:int

position to read the first integer of data from.

Returns:ObjectId

the converted object id.

fromStringback to summary
public static final ObjectId fromString(byte[] buf, int offset)

Convert an ObjectId from hex characters (US-ASCII).

Parameters
buf:byte[]

the US-ASCII buffer to read from. At least 40 bytes after offset must be available within this byte array.

offset:int

position to read the first character from.

Returns:ObjectId

the converted object id.

fromStringback to summary
public static ObjectId fromString(String str)

Convert an ObjectId from hex characters.

Parameters
str:String

the string to read from. Must be 40 characters long.

Returns:ObjectId

the converted object id.

isIdback to summary
public static final boolean isId(String id)

Test a string of characters to verify it is a hex format.

If true the string can be parsed with fromString(String).

Parameters
id:String

the string to test.

Returns:boolean

true if the string can converted into an ObjectId.

readObjectback to summary
private void readObject(ObjectInputStream ois) throws IOException
toObjectIdback to summary
public ObjectId toObjectId()

Implements abstract org.eclipse.jgit.lib.AnyObjectId.toObjectId.

Doc from org.eclipse.jgit.lib.AnyObjectId.toObjectId.

Obtain an immutable copy of this current object name value.

See copy() if this is a possibly subclassed (but immutable) identity and the application needs a lightweight identity only reference.

Returns:ObjectId

an immutable copy. May be this if this is already an immutable instance.

Annotations
@Override
toStringback to summary
public static final String toString(ObjectId i)

Convert an ObjectId into a hex string representation.

Parameters
i:ObjectId

the id to convert. May be null.

Returns:String

the hex string conversion of this id's content.

writeObjectback to summary
private void writeObject(ObjectOutputStream os) throws IOException
zeroIdback to summary
public static final ObjectId zeroId()

Get the special all-null ObjectId.

Returns:ObjectId

the all-null ObjectId, often used to stand-in for no object.