public final class AbbreviatedObjectId extends Object implements Serializable
ObjectId
.
Sometimes Git produces abbreviated SHA-1 strings, using sufficient leading digits from the ObjectId 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.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static AbbreviatedObjectId |
fromObjectId(AnyObjectId id)
Convert an AbbreviatedObjectId from an
AnyObjectId . |
static AbbreviatedObjectId |
fromString(byte[] buf,
int offset,
int end)
Convert an AbbreviatedObjectId from hex characters (US-ASCII).
|
static AbbreviatedObjectId |
fromString(String str)
Convert an AbbreviatedObjectId from hex characters.
|
int |
getFirstByte() |
int |
hashCode() |
boolean |
isComplete() |
static boolean |
isId(String id)
Test a string of characters to verify it is a hex format.
|
int |
length() |
String |
name() |
int |
prefixCompare(AnyObjectId other)
Compares this abbreviation to a full object id.
|
int |
prefixCompare(byte[] bs,
int p)
Compare this abbreviation to a network-byte-order ObjectId.
|
int |
prefixCompare(int[] bs,
int p)
Compare this abbreviation to a network-byte-order ObjectId.
|
ObjectId |
toObjectId() |
String |
toString() |
public static final boolean isId(String id)
If true the string can be parsed with fromString(String)
.
id
- the string to test.public static final AbbreviatedObjectId 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 AbbreviatedObjectId fromObjectId(AnyObjectId 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 AbbreviatedObjectId fromString(String str)
str
- the string to read from. Must be <= 40 characters.public int length()
public boolean isComplete()
public ObjectId toObjectId()
isComplete()
is falsepublic final int prefixCompare(AnyObjectId 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 ObjectId in network byte order.p
- position within bs
to start the compare at. At least
20 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(int[] bs, int p)
bs
- array containing the other ObjectId in network byte order.p
- position within bs
to start the compare at. At least 5
ints, 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()
public final String name()
Copyright © 2015 Eclipse JGit Project. All rights reserved.