Package org.eclipse.jgit.lib
Class ObjectId
java.lang.Object
org.eclipse.jgit.lib.AnyObjectId
org.eclipse.jgit.lib.ObjectId
- All Implemented Interfaces:
Serializable
,Comparable<AnyObjectId>
- Direct Known Subclasses:
BitmapCommit
,DfsPackCompactor.ObjectIdWithOffset
,NonNoteEntry
,Note
,ObjectIdOwnerMap.Entry
,PackBitmapIndexRemapper.Entry
A SHA-1 abstraction.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionObjectId
(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.protected
ObjectId
(AnyObjectId src) Initialize this instance by copying another existing ObjectId. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
equals
(byte[] firstBuffer, int fi, byte[] secondBuffer, int si) Compare two object identifier byte sequences for equality.private static final ObjectId
fromHexString
(byte[] bs, int p) static final ObjectId
fromRaw
(byte[] bs) Convert an ObjectId from raw binary representation.static final ObjectId
fromRaw
(byte[] bs, int p) Convert an ObjectId from raw binary representation.static final ObjectId
fromRaw
(int[] is) Convert an ObjectId from raw binary representation.static final ObjectId
fromRaw
(int[] is, int p) Convert an ObjectId from raw binary representation.static final ObjectId
fromString
(byte[] buf, int offset) Convert an ObjectId from hex characters (US-ASCII).static ObjectId
fromString
(String str) Convert an ObjectId from hex characters.static final boolean
Test a string of characters to verify it is a hex format.private void
Obtain an immutable copy of this current object name value.static final String
Convert an ObjectId into a hex string representation.private void
static final ObjectId
zeroId()
Get the special all-null ObjectId.Methods inherited from class org.eclipse.jgit.lib.AnyObjectId
abbreviate, compareTo, compareTo, compareTo, copy, copyRawTo, copyRawTo, copyRawTo, copyRawTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, equals, equals, equals, formatHexChar, getByte, getFirstByte, getName, hashCode, isEqual, name, startsWith, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ZEROID
-
ZEROID_STR
-
-
Constructor Details
-
ObjectId
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
- an intnew_2
- an intnew_3
- an intnew_4
- an intnew_5
- an int- Since:
- 4.7
-
ObjectId
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
- another already parsed ObjectId to copy the value out of.
-
-
Method Details
-
zeroId
Get the special all-null ObjectId.- Returns:
- the all-null ObjectId, often used to stand-in for no object.
-
isId
Test a string of characters to verify it is a hex format.If true the string can be parsed with
fromString(String)
.- Parameters:
id
- the string to test.- Returns:
- true if the string can converted into an ObjectId.
-
toString
Convert an ObjectId into a hex string representation.- Parameters:
i
- the id to convert. May be null.- Returns:
- the hex string conversion of this id's content.
-
equals
public static boolean equals(byte[] firstBuffer, int fi, byte[] secondBuffer, int si) Compare two object identifier byte sequences for equality.- Parameters:
firstBuffer
- the first buffer to compare against. Must have at least 20 bytes from position fi through the end of the buffer.fi
- first offset within firstBuffer to begin testing.secondBuffer
- the second buffer to compare against. Must have at least 20 bytes from position si through the end of the buffer.si
- first offset within secondBuffer to begin testing.- Returns:
- true if the two identifiers are the same.
-
fromRaw
Convert an ObjectId from raw binary representation.- Parameters:
bs
- the raw byte buffer to read from. At least 20 bytes must be available within this byte array.- Returns:
- the converted object id.
-
fromRaw
Convert an ObjectId from raw binary representation.- Parameters:
bs
- the raw byte buffer to read from. At least 20 bytes after p must be available within this byte array.p
- position to read the first byte of data from.- Returns:
- the converted object id.
-
fromRaw
Convert an ObjectId from raw binary representation.- Parameters:
is
- the raw integers buffer to read from. At least 5 integers must be available within this int array.- Returns:
- the converted object id.
-
fromRaw
Convert an ObjectId from raw binary representation.- Parameters:
is
- the raw integers buffer to read from. At least 5 integers after p must be available within this int array.p
- position to read the first integer of data from.- Returns:
- the converted object id.
-
fromString
Convert an ObjectId from hex characters (US-ASCII).- Parameters:
buf
- the US-ASCII buffer to read from. At least 40 bytes after offset must be available within this byte array.offset
- position to read the first character from.- Returns:
- the converted object id.
-
fromString
Convert an ObjectId from hex characters.- Parameters:
str
- the string to read from. Must be 40 characters long.- Returns:
- the converted object id.
-
fromHexString
-
toObjectId
Obtain an immutable copy of this current object name value.See
AnyObjectId.copy()
ifthis
is a possibly subclassed (but immutable) identity and the application needs a lightweight identity only reference.- Specified by:
toObjectId
in classAnyObjectId
- Returns:
- an immutable copy. May be
this
if this is already an immutable instance.
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOException
-