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

public class ObjectId extends AnyObjectId implements Serializable
A SHA-1 abstraction.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • ZEROID

      private static final ObjectId ZEROID
    • ZEROID_STR

      private static final String 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 int
      new_2 - an int
      new_3 - an int
      new_4 - an int
      new_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 Details

    • 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 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 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(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() 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.
    • writeObject

      private void writeObject(ObjectOutputStream os) throws IOException
      Throws:
      IOException
    • readObject

      private void readObject(ObjectInputStream ois) throws IOException
      Throws:
      IOException