public final class AbbreviatedLongObjectId
extends java.lang.Object
implements java.io.Serializable
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 AbbreviatedObjectId
Modifier and Type | Field and Description |
---|---|
(package private) int |
nibbles
Number of half-bytes used by this id.
|
private static long |
serialVersionUID |
(package private) long |
w1 |
(package private) long |
w2 |
(package private) long |
w3 |
(package private) long |
w4 |
Constructor and Description |
---|
AbbreviatedLongObjectId(int n,
long new_1,
long new_2,
long new_3,
long new_4) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
private static AbbreviatedLongObjectId |
fromHexString(byte[] bs,
int ptr,
int end) |
static AbbreviatedLongObjectId |
fromLongObjectId(AnyLongObjectId id)
Convert an AbbreviatedObjectId from an
AnyObjectId . |
static AbbreviatedLongObjectId |
fromString(byte[] buf,
int offset,
int end)
Convert an AbbreviatedObjectId from hex characters (US-ASCII).
|
static AbbreviatedLongObjectId |
fromString(java.lang.String str)
Convert an AbbreviatedLongObjectId from hex characters.
|
int |
getFirstByte()
Get the first byte of this id
|
int |
hashCode() |
private static long |
hexUInt64(byte[] bs,
int p,
int end) |
boolean |
isComplete()
Check if this id is complete
|
static boolean |
isId(java.lang.String id)
Test a string of characters to verify it is a hex format.
|
int |
length()
Get length
|
(package private) static long |
mask(int nibbles,
long word,
long v) |
private long |
mask(long word,
long v) |
java.lang.String |
name()
name.
|
int |
prefixCompare(AnyLongObjectId other)
Compares this abbreviation to a full object id.
|
int |
prefixCompare(byte[] bs,
int p)
Compare this abbreviation to a network-byte-order LongObjectId.
|
int |
prefixCompare(long[] bs,
int p)
Compare this abbreviation to a network-byte-order LongObjectId.
|
LongObjectId |
toLongObjectId()
Convert to LongObjectId
|
java.lang.String |
toString() |
private static final long serialVersionUID
final int nibbles
final long w1
final long w2
final long w3
final long w4
AbbreviatedLongObjectId(int n, long new_1, long new_2, long new_3, long new_4)
public static final boolean isId(java.lang.String id)
If true the string can be parsed with fromString(String)
.
id
- the string to test.public static final AbbreviatedLongObjectId fromString(byte[] buf, int offset, int end)
buf
- the US-ASCII buffer to read from.offset
- position to read the first character from.end
- one past the last position to read (end-offset
is
the length of the string).public static final AbbreviatedLongObjectId fromLongObjectId(AnyLongObjectId id)
AnyObjectId
.
This method copies over all bits of the Id, and is therefore complete
(see isComplete()
).
id
- the ObjectId
to convert from.public static final AbbreviatedLongObjectId fromString(java.lang.String str)
str
- the string to read from. Must be <= 64 characters.private static final AbbreviatedLongObjectId fromHexString(byte[] bs, int ptr, int end)
private static final long hexUInt64(byte[] bs, int p, int end)
static long mask(int nibbles, long word, long v)
public int length()
public boolean isComplete()
public LongObjectId toLongObjectId()
isComplete()
is false.public final int prefixCompare(AnyLongObjectId other)
other
- the other object id.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
.public final int prefixCompare(byte[] bs, int p)
bs
- array containing the other LongObjectId in network byte order.p
- position within bs
to start the compare at. At least
32 bytes, starting at this position are required.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
.public final int prefixCompare(long[] bs, int p)
bs
- array containing the other LongObjectId in network byte order.p
- position within bs
to start the compare at. At least 4
longs, starting at this position are required.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
.public final int getFirstByte()
private long mask(long word, long v)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final java.lang.String name()
name.
public java.lang.String toString()
toString
in class java.lang.Object