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:
  Note, ObjectIdOwnerMap.Entry, PackBitmapIndexRemapper.Entry

    public class ObjectId
    extends AnyObjectId
    implements Serializable

A SHA-1 abstraction.

See Also:
  Serialized Form

### Constructor Summary

Constructors
`protected` `ObjectId(AnyObjectId src)` Initialize this instance by copying another existing ObjectId.

### Method Summary

Methods
`static boolean` `equals(byte[] firstBuffer, int fi, byte[] secondBuffer, int si)` Compare to object identifier byte sequences for equality.
`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(String str)` Convert an ObjectId from hex characters.
`static boolean` `isId(String id)` Test a string of characters to verify it is a hex format.
`ObjectId` `toObjectId()` Obtain an immutable copy of this current object name value.
`static String` `toString(ObjectId i)` Convert an ObjectId into a hex string representation.
`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, getByte, getFirstByte, getName, hashCode, name, startsWith, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### 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(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 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 to object identifier byte sequences for equality.

Parameters:
  `firstBuffer` - the first buffer to compare against. Must have at least 20 bytes from position ai 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 2 bytes from position bi 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(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.

#### toObjectId

    public ObjectId toObjectId()

Description copied from class: `AnyObjectId`
Obtain an immutable copy of this current object name value.

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

Specified by:
  `toObjectId` in class `AnyObjectId`
Returns:
  an immutable copy. May be `this` if this is already an immutable instance.