public abstract class AnyLongObjectId extends Object implements Comparable<AnyLongObjectId>
If this is an instance of
MutableLongObjectId
the concept of equality
with this instance can alter at any time, if this instance is modified to
represent a different object name.
Ported to SHA-256 from AnyObjectId
Constructor and Description |
---|
AnyLongObjectId() |
Modifier and Type | Method and Description |
---|---|
AbbreviatedLongObjectId |
abbreviate(int len)
Return an abbreviation (prefix) of this object SHA-256.
|
int |
compareTo(AnyLongObjectId other)
Compare this LongObjectId to another and obtain a sort ordering.
|
int |
compareTo(byte[] bs,
int p)
Compare this LongObjectId to a network-byte-order LongObjectId.
|
int |
compareTo(long[] bs,
int p)
Compare this LongObjectId to a network-byte-order LongObjectId.
|
LongObjectId |
copy()
Obtain an immutable copy of this current object.
|
void |
copyRawTo(byte[] b,
int o)
Copy this LongObjectId to a byte array.
|
void |
copyRawTo(ByteBuffer w)
Copy this LongObjectId to an output writer in raw binary.
|
void |
copyRawTo(long[] b,
int o)
Copy this LongObjectId to an long array.
|
void |
copyRawTo(OutputStream w)
Copy this LongObjectId to an output writer in raw binary.
|
void |
copyTo(byte[] b,
int o)
Copy this LongObjectId to a byte array in hex format.
|
void |
copyTo(ByteBuffer b)
Copy this LongObjectId to a ByteBuffer in hex format.
|
void |
copyTo(char[] tmp,
StringBuilder w)
Copy this LongObjectId to a StringBuilder in hex format.
|
void |
copyTo(char[] tmp,
Writer w)
Copy this LongObjectId to an output writer in hex format.
|
void |
copyTo(OutputStream w)
Copy this LongObjectId to an output writer in hex format.
|
void |
copyTo(Writer w)
Copy this LongObjectId to an output writer in hex format.
|
boolean |
equals(AnyLongObjectId other)
Determine if this LongObjectId has exactly the same value as another.
|
static boolean |
equals(AnyLongObjectId firstObjectId,
AnyLongObjectId secondObjectId)
Deprecated.
use
isEqual(AnyLongObjectId, AnyLongObjectId)
instead. |
boolean |
equals(Object o) |
int |
getByte(int index)
Get any byte from the LongObjectId.
|
int |
getFirstByte()
Get the first 8 bits of the LongObjectId.
|
String |
getName()
Get string form of the SHA-256
|
int |
getSecondByte()
Get the second 8 bits of the LongObjectId.
|
int |
hashCode() |
static boolean |
isEqual(AnyLongObjectId firstObjectId,
AnyLongObjectId secondObjectId)
Compare two object identifier byte sequences for equality.
|
String |
name()
Get string form of the SHA-256
|
boolean |
startsWith(AbbreviatedLongObjectId abbr)
Tests if this LongObjectId starts with the given abbreviation.
|
abstract LongObjectId |
toObjectId()
Obtain an immutable copy of this current object.
|
String |
toString() |
@Deprecated public static boolean equals(AnyLongObjectId firstObjectId, AnyLongObjectId secondObjectId)
isEqual(AnyLongObjectId, AnyLongObjectId)
instead.firstObjectId
- the first identifier to compare. Must not be null.secondObjectId
- the second identifier to compare. Must not be null.public static boolean isEqual(AnyLongObjectId firstObjectId, AnyLongObjectId secondObjectId)
firstObjectId
- the first identifier to compare. Must not be null.secondObjectId
- the second identifier to compare. Must not be null.public final int getFirstByte()
getByte(0)
.public final int getSecondByte()
public final int getByte(int index)
getByte(0)
should instead use the much faster
special case variant getFirstByte()
.index
- index of the byte to obtain from the raw form of the
LongObjectId. Must be in range [0,
Constants.LONG_OBJECT_ID_LENGTH
).index
. Returned values
are unsigned and thus are in the range [0,255] rather than the
signed byte range of [-128, 127].ArrayIndexOutOfBoundsException
- index
is less than 0, equal to
Constants.LONG_OBJECT_ID_LENGTH
,
or greater than
Constants.LONG_OBJECT_ID_LENGTH
.public final int compareTo(AnyLongObjectId other)
compareTo
in interface Comparable<AnyLongObjectId>
public final int compareTo(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.public final int compareTo(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.public boolean startsWith(AbbreviatedLongObjectId abbr)
abbr
- the abbreviation.public final boolean equals(AnyLongObjectId other)
other
- the other id to compare to. May be null.public void copyRawTo(ByteBuffer w)
w
- the buffer to copy to. Must be in big endian order.public void copyRawTo(byte[] b, int o)
b
- the buffer to copy to.o
- the offset within b to write at.public void copyRawTo(long[] b, int o)
b
- the buffer to copy to.o
- the offset within b to write at.public void copyRawTo(OutputStream w) throws IOException
w
- the stream to write to.IOException
- the stream writing failed.public void copyTo(OutputStream w) throws IOException
w
- the stream to copy to.IOException
- the stream writing failed.public void copyTo(byte[] b, int o)
b
- the buffer to copy to.o
- the offset within b to write at.public void copyTo(ByteBuffer b)
b
- the buffer to copy to.public void copyTo(Writer w) throws IOException
w
- the stream to copy to.IOException
- the stream writing failed.public void copyTo(char[] tmp, Writer w) throws IOException
tmp
- temporary char array to buffer construct into before writing.
Must be at least large enough to hold 2 digits for each byte
of object id (64 characters or larger).w
- the stream to copy to.IOException
- the stream writing failed.public void copyTo(char[] tmp, StringBuilder w)
tmp
- temporary char array to buffer construct into before writing.
Must be at least large enough to hold 2 digits for each byte
of object id (64 characters or larger).w
- the string to append onto.public final String name()
public final String getName()
public AbbreviatedLongObjectId abbreviate(int len)
This implementation does not guarantee uniqueness. Callers should instead
use
ObjectReader.abbreviate(AnyObjectId, int)
to
obtain a unique abbreviation within the scope of a particular object
database.
len
- length of the abbreviated string.public final LongObjectId copy()
Only returns this
if this instance is an unsubclassed
instance of LongObjectId
; otherwise a
new instance is returned holding the same value.
This method is useful to shed any additional memory that may be tied to the subclass, yet retain the unique identity of the object id for future lookups within maps and repositories.
public abstract LongObjectId toObjectId()
See copy()
if this
is a possibly subclassed (but
immutable) identity and the application needs a lightweight identity
only reference.
this
if this is already an
immutable instance.Copyright © 2021 Eclipse JGit Project. All rights reserved.