Package org.eclipse.jgit.lib
Class ObjectId
- java.lang.Object
-
- org.eclipse.jgit.lib.AnyObjectId
-
- org.eclipse.jgit.lib.ObjectId
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnyObjectId>
- Direct Known Subclasses:
BitmapCommit
,DfsPackCompactor.ObjectIdWithOffset
,NonNoteEntry
,Note
,ObjectIdOwnerMap.Entry
,PackBitmapIndexRemapper.Entry
public class ObjectId extends AnyObjectId implements java.io.Serializable
A SHA-1 abstraction.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
private static ObjectId
ZEROID
private static java.lang.String
ZEROID_STR
-
Constructor Summary
Constructors Modifier Constructor Description 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.protected
ObjectId(AnyObjectId src)
Initialize this instance by copying another existing ObjectId.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
equals(byte[] firstBuffer, int fi, byte[] secondBuffer, int si)
Compare two object identifier byte sequences for equality.private static ObjectId
fromHexString(byte[] bs, int p)
static ObjectId
fromRaw(byte[] bs)
Convert an ObjectId from raw binary representation.static ObjectId
fromRaw(byte[] bs, int p)
Convert an ObjectId from raw binary representation.static ObjectId
fromRaw(int[] is)
Convert an ObjectId from raw binary representation.static ObjectId
fromRaw(int[] is, int p)
Convert an ObjectId from raw binary representation.static ObjectId
fromString(byte[] buf, int offset)
Convert an ObjectId from hex characters (US-ASCII).static ObjectId
fromString(java.lang.String str)
Convert an ObjectId from hex characters.static boolean
isId(java.lang.String id)
Test a string of characters to verify it is a hex format.private void
readObject(java.io.ObjectInputStream ois)
ObjectId
toObjectId()
Obtain an immutable copy of this current object name value.static java.lang.String
toString(ObjectId i)
Convert an ObjectId into a hex string representation.private void
writeObject(java.io.ObjectOutputStream os)
static 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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ZEROID
private static final ObjectId ZEROID
-
ZEROID_STR
private static final java.lang.String ZEROID_STR
-
-
Constructor Detail
-
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
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
- another already parsed ObjectId to copy the value out of.
-
-
Method Detail
-
zeroId
public static final ObjectId zeroId()
Get the special all-null ObjectId.- Returns:
- the all-null ObjectId, often used to stand-in for no object.
-
isId
public static final boolean isId(@Nullable java.lang.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
- the string to test.- Returns:
- true if the string can converted into an ObjectId.
-
toString
public static final java.lang.String toString(ObjectId i)
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
public static final ObjectId fromRaw(byte[] bs)
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
public static final ObjectId fromRaw(byte[] bs, int p)
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
public static final ObjectId fromRaw(int[] is)
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
public static final ObjectId fromRaw(int[] is, int p)
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
public static final ObjectId fromString(byte[] buf, int offset)
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
public static ObjectId fromString(java.lang.String str)
Convert an ObjectId from hex characters.- Parameters:
str
- the string to read from. Must be 40 characters long.- Returns:
- the converted object id.
-
fromHexString
private static final ObjectId fromHexString(byte[] bs, int p)
-
toObjectId
public ObjectId 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
private void writeObject(java.io.ObjectOutputStream os) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream ois) throws java.io.IOException
- Throws:
java.io.IOException
-
-