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

public final Class AbbreviatedLongObjectId

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.text.MessageFormat, org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException, org.eclipse.jgit.lfs.internal.LfsText, org.eclipse.jgit.util.NB, .RawParseUtils

A prefix abbreviation of an org.eclipse.jgit.lfs.lib.LongObjectId.

Enable abbreviating SHA-256 strings used by Git LFS, using sufficient leading digits from the LongObjectId name to still be unique within the repository the string was generated from. These ids are likely to be unique for a useful period of time, especially if they contain at least 6-10 hex digits.

This class converts the hex string into a binary form, to make it more efficient for matching against an object. Ported to SHA-256 from org.eclipse.jgit.lib.AbbreviatedObjectId

Since
4.3

Field Summary

Modifier and TypeField and Description
pack-priv final int
nibbles

Number of half-bytes used by this id.

private static final long
pack-priv final long
pack-priv final long
pack-priv final long
pack-priv final long

Constructor Summary

AccessConstructor and Description
pack-priv
AbbreviatedLongObjectId(final int n, final long new_1, final long new_2, final long new_3, final long new_4)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

private static final AbbreviatedLongObjectId
fromHexString(final byte[] bs, int ptr, final int end)

public static final AbbreviatedLongObjectId

Returns:

the converted object id.
fromLongObjectId
(AnyLongObjectId
the org.eclipse.jgit.lib.ObjectId to convert from.
id
)

Convert an AbbreviatedObjectId from an org.eclipse.jgit.lib.AnyObjectId.

public static final AbbreviatedLongObjectId

Returns:

the converted object id.
fromString
(final byte[]
the US-ASCII buffer to read from.
buf
,
final int
position to read the first character from.
offset
,
final int
one past the last position to read (end-offset is the length of the string).
end
)

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

public static final AbbreviatedLongObjectId

Returns:

the converted object id.
fromString
(String
the string to read from. Must be <= 64 characters.
str
)

Convert an AbbreviatedLongObjectId from hex characters.

public final int

Returns:

value for a fan-out style map, only valid of length >= 2.
getFirstByte
()

Get the first byte of this id

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private static final long
hexUInt64(final byte[] bs, int p, final int end)

public boolean

Returns:

true if this ObjectId is actually a complete id.
isComplete
()

Check if this id is complete

public static final boolean

Returns:

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

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

public int

Returns:

number of hex digits appearing in this id.
length
()

Get length

pack-priv static long
mask(int nibbles, long word, long v)

private long
mask(long word, long v)

public final String

Returns:

string form of the abbreviation, in lower case hexadecimal.
name
()

name.

public final int

Returns:

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.
prefixCompare
(AnyLongObjectId
the other object id.
other
)

Compares this abbreviation to a full object id.

public final int

Returns:

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.
prefixCompare
(byte[]
array containing the other LongObjectId in network byte order.
bs
,
int
position within bs to start the compare at. At least 32 bytes, starting at this position are required.
p
)

Compare this abbreviation to a network-byte-order LongObjectId.

public final int

Returns:

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.
prefixCompare
(long[]
array containing the other LongObjectId in network byte order.
bs
,
int
position within bs to start the compare at. At least 4 longs, starting at this position are required.
p
)

Compare this abbreviation to a network-byte-order LongObjectId.

public LongObjectId

Returns:

a complete ObjectId; null if isComplete() is false.
toLongObjectId
()

Convert to LongObjectId

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nibblesback to summary
pack-priv final int nibbles

Number of half-bytes used by this id.

serialVersionUIDback to summary
private static final long serialVersionUID
w1back to summary
pack-priv final long w1
w2back to summary
pack-priv final long w2
w3back to summary
pack-priv final long w3
w4back to summary
pack-priv final long w4

Constructor Detail

AbbreviatedLongObjectIdback to summary
pack-priv AbbreviatedLongObjectId(final int n, final long new_1, final long new_2, final long new_3, final long new_4)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fromHexStringback to summary
private static final AbbreviatedLongObjectId fromHexString(final byte[] bs, int ptr, final int end)
fromLongObjectIdback to summary
public static final AbbreviatedLongObjectId fromLongObjectId(AnyLongObjectId id)

Convert an AbbreviatedObjectId from an org.eclipse.jgit.lib.AnyObjectId.

This method copies over all bits of the Id, and is therefore complete (see isComplete()).

Parameters
id:AnyLongObjectId

the org.eclipse.jgit.lib.ObjectId to convert from.

Returns:AbbreviatedLongObjectId

the converted object id.

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

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

Parameters
buf:byte[]

the US-ASCII buffer to read from.

offset:int

position to read the first character from.

end:int

one past the last position to read (end-offset is the length of the string).

Returns:AbbreviatedLongObjectId

the converted object id.

fromStringback to summary
public static final AbbreviatedLongObjectId fromString(String str)

Convert an AbbreviatedLongObjectId from hex characters.

Parameters
str:String

the string to read from. Must be <= 64 characters.

Returns:AbbreviatedLongObjectId

the converted object id.

getFirstByteback to summary
public final int getFirstByte()

Get the first byte of this id

Returns:int

value for a fan-out style map, only valid of length >= 2.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hexUInt64back to summary
private static final long hexUInt64(final byte[] bs, int p, final int end)
isCompleteback to summary
public boolean isComplete()

Check if this id is complete

Returns:boolean

true if this ObjectId is actually a complete 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 AbbreviatedObjectId.

lengthback to summary
public int length()

Get length

Returns:int

number of hex digits appearing in this id.

maskback to summary
pack-priv static long mask(int nibbles, long word, long v)
maskback to summary
private long mask(long word, long v)
nameback to summary
public final String name()

name.

Returns:String

string form of the abbreviation, in lower case hexadecimal.

prefixCompareback to summary
public final int prefixCompare(AnyLongObjectId other)

Compares this abbreviation to a full object id.

Parameters
other:AnyLongObjectId

the other object id.

Returns:int

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.

prefixCompareback to summary
public final int prefixCompare(byte[] bs, int p)

Compare this abbreviation to a network-byte-order LongObjectId.

Parameters
bs:byte[]

array containing the other LongObjectId in network byte order.

p:int

position within bs to start the compare at. At least 32 bytes, starting at this position are required.

Returns:int

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.

prefixCompareback to summary
public final int prefixCompare(long[] bs, int p)

Compare this abbreviation to a network-byte-order LongObjectId.

Parameters
bs:long[]

array containing the other LongObjectId in network byte order.

p:int

position within bs to start the compare at. At least 4 longs, starting at this position are required.

Returns:int

<0 if this abbreviation names an object that is less than other; 0 if this abbreviation exactly matches the first length() digits of other.name(); >0 if this abbreviation names an object that is after other.

toLongObjectIdback to summary
public LongObjectId toLongObjectId()

Convert to LongObjectId

Returns:LongObjectId

a complete ObjectId; null if isComplete() is false.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override