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

public abstract Class AnyLongObjectId

extends Object
implements Comparable<AnyLongObjectId>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Known Direct Subclasses
org.eclipse.jgit.lfs.lib.LongObjectId, org.eclipse.jgit.lfs.lib.MutableLongObjectId
Imports
java.io.IOException, .OutputStream, .Writer, java.nio.ByteBuffer, org.eclipse.jgit.lib.AnyObjectId, org.eclipse.jgit.util.NB, .References

A (possibly mutable) SHA-256 abstraction.

If this is an instance of org.eclipse.jgit.lfs.lib.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 org.eclipse.jgit.lib.AnyObjectId

Since
4.3

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final char[]
pack-priv long
pack-priv long
pack-priv long
pack-priv long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AbbreviatedLongObjectId

Returns:

SHA-256 abbreviation.
abbreviate
(int
length of the abbreviated string.
len
)

Return an abbreviation (prefix) of this object SHA-256.

public final int
compareTo(AnyLongObjectId
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public final int

Returns:

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
compareTo
(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 LongObjectId to a network-byte-order LongObjectId.

public final int

Returns:

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
compareTo
(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 LongObjectId to a network-byte-order LongObjectId.

public final LongObjectId

Returns:

an immutable copy, using the smallest memory footprint possible.
copy
()

Obtain an immutable copy of this current object.

public void
copyRawTo(ByteBuffer
the buffer to copy to. Must be in big endian order.
w
)

Copy this LongObjectId to an output writer in raw binary.

public void
copyRawTo(byte[]
the buffer to copy to.
b
,
int
the offset within b to write at.
o
)

Copy this LongObjectId to a byte array.

public void
copyRawTo(long[]
the buffer to copy to.
b
,
int
the offset within b to write at.
o
)

Copy this LongObjectId to an long array.

public void
copyRawTo(OutputStream
the stream to write to.
w
)

Copy this LongObjectId to an output writer in raw binary.

public void
copyTo(OutputStream
the stream to copy to.
w
)

Copy this LongObjectId to an output writer in hex format.

public void
copyTo(byte[]
the buffer to copy to.
b
,
int
the offset within b to write at.
o
)

Copy this LongObjectId to a byte array in hex format.

public void
copyTo(ByteBuffer
the buffer to copy to.
b
)

Copy this LongObjectId to a ByteBuffer in hex format.

public void
copyTo(Writer
the stream to copy to.
w
)

Copy this LongObjectId to an output writer in hex format.

public void
copyTo(char[]
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).
tmp
,
Writer
the stream to copy to.
w
)

Copy this LongObjectId to an output writer in hex format.

public void
copyTo(char[]
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).
tmp
,
StringBuilder
the string to append onto.
w
)

Copy this LongObjectId to a StringBuilder in hex format.

public final boolean

Returns:

true only if both LongObjectIds have identical bits.
equals
(AnyLongObjectId
the other id to compare to. May be null.
other
)

Determine if this LongObjectId has exactly the same value as another.

public final 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 void
formatHexByte(byte[] dst, int p, long w)

pack-priv static void
formatHexChar(char[] dst, int p, long w)

public final int

Returns:

the value of the requested byte at index. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].
getByte
(int
index of the byte to obtain from the raw form of the LongObjectId. Must be in range [0, org.eclipse.jgit.lfs.lib.Constants#LONG_OBJECT_ID_LENGTH).
index
)

Get any byte from the LongObjectId.

public final int

Returns:

a discriminator usable for a fan-out style map. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].
getFirstByte
()

Get the first 8 bits of the LongObjectId.

public final String

Returns:

string form of the SHA-256, in lower case hexadecimal.
getName
()

Get string form of the SHA-256

public final int

Returns:

a discriminator usable for a fan-out style map. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].
getSecondByte
()

Get the second 8 bits of the LongObjectId.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static boolean

Returns:

true if the two identifiers are the same.
isEqual
(final AnyLongObjectId
the first identifier to compare. Must not be null.
firstObjectId
,
final AnyLongObjectId
the second identifier to compare. Must not be null.
secondObjectId
)

Compare two object identifier byte sequences for equality.

public final String

Returns:

string form of the SHA-256, in lower case hexadecimal.
name
()

Get string form of the SHA-256

public boolean

Returns:

true if this LongObjectId begins with the abbreviation; else false.
startsWith
(AbbreviatedLongObjectId
the abbreviation.
abbr
)

Tests if this LongObjectId starts with the given abbreviation.

private byte[]
pack-priv char[]
private void
toHexCharArray(char[] dst)

public abstract LongObjectId

Returns:

an immutable copy. May be this if this is already an immutable instance.
toObjectId
()

Obtain an immutable copy of this current object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

hexbyteback to summary
private static final byte[] hexbyte
hexcharback to summary
private static final char[] hexchar
w1back to summary
pack-priv long w1
w2back to summary
pack-priv long w2
w3back to summary
pack-priv long w3
w4back to summary
pack-priv long w4

Constructor Detail

AnyLongObjectIdback to summary
public AnyLongObjectId()

Method Detail

abbreviateback to summary
public AbbreviatedLongObjectId abbreviate(int len)

Return an abbreviation (prefix) of this object SHA-256.

This implementation does not guarantee uniqueness. Callers should instead use org.eclipse.jgit.lib.ObjectReader#abbreviate(AnyObjectId, int) to obtain a unique abbreviation within the scope of a particular object database.

Parameters
len:int

length of the abbreviated string.

Returns:AbbreviatedLongObjectId

SHA-256 abbreviation.

compareToback to summary
public final int compareTo(AnyLongObjectId other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z. Compare this LongObjectId to another and obtain a sort ordering.

Parameters
other:AnyLongObjectId

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
compareToback to summary
public final int compareTo(byte[] bs, int p)

Compare this LongObjectId 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

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareToback to summary
public final int compareTo(long[] bs, int p)

Compare this LongObjectId 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

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

copyback to summary
public final LongObjectId copy()

Obtain an immutable copy of this current object.

Only returns this if this instance is an unsubclassed instance of org.eclipse.jgit.lfs.lib.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.

Returns:LongObjectId

an immutable copy, using the smallest memory footprint possible.

copyRawToback to summary
public void copyRawTo(ByteBuffer w)

Copy this LongObjectId to an output writer in raw binary.

Parameters
w:ByteBuffer

the buffer to copy to. Must be in big endian order.

copyRawToback to summary
public void copyRawTo(byte[] b, int o)

Copy this LongObjectId to a byte array.

Parameters
b:byte[]

the buffer to copy to.

o:int

the offset within b to write at.

copyRawToback to summary
public void copyRawTo(long[] b, int o)

Copy this LongObjectId to an long array.

Parameters
b:long[]

the buffer to copy to.

o:int

the offset within b to write at.

copyRawToback to summary
public void copyRawTo(OutputStream w) throws IOException

Copy this LongObjectId to an output writer in raw binary.

Parameters
w:OutputStream

the stream to write to.

Exceptions
IOException:
the stream writing failed.
copyToback to summary
public void copyTo(OutputStream w) throws IOException

Copy this LongObjectId to an output writer in hex format.

Parameters
w:OutputStream

the stream to copy to.

Exceptions
IOException:
the stream writing failed.
copyToback to summary
public void copyTo(byte[] b, int o)

Copy this LongObjectId to a byte array in hex format.

Parameters
b:byte[]

the buffer to copy to.

o:int

the offset within b to write at.

copyToback to summary
public void copyTo(ByteBuffer b)

Copy this LongObjectId to a ByteBuffer in hex format.

Parameters
b:ByteBuffer

the buffer to copy to.

copyToback to summary
public void copyTo(Writer w) throws IOException

Copy this LongObjectId to an output writer in hex format.

Parameters
w:Writer

the stream to copy to.

Exceptions
IOException:
the stream writing failed.
copyToback to summary
public void copyTo(char[] tmp, Writer w) throws IOException

Copy this LongObjectId to an output writer in hex format.

Parameters
tmp:char[]

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:Writer

the stream to copy to.

Exceptions
IOException:
the stream writing failed.
copyToback to summary
public void copyTo(char[] tmp, StringBuilder w)

Copy this LongObjectId to a StringBuilder in hex format.

Parameters
tmp:char[]

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:StringBuilder

the string to append onto.

equalsback to summary
public final boolean equals(AnyLongObjectId other)

Determine if this LongObjectId has exactly the same value as another.

Parameters
other:AnyLongObjectId

the other id to compare to. May be null.

Returns:boolean

true only if both LongObjectIds have identical bits.

Annotations
@SuppressWarnings:NonOverridingEquals, AmbiguousMethodReference
equalsback to summary
public final 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
formatHexByteback to summary
private static void formatHexByte(byte[] dst, int p, long w)
formatHexCharback to summary
pack-priv static void formatHexChar(char[] dst, int p, long w)
getByteback to summary
public final int getByte(int index)

Get any byte from the LongObjectId. Callers hard-coding getByte(0) should instead use the much faster special case variant getFirstByte().

Parameters
index:int

index of the byte to obtain from the raw form of the LongObjectId. Must be in range [0, org.eclipse.jgit.lfs.lib.Constants#LONG_OBJECT_ID_LENGTH).

Returns:int

the value of the requested byte at index. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].

Exceptions
ArrayIndexOutOfBoundsException:
index is less than 0, equal to org.eclipse.jgit.lfs.lib.Constants#LONG_OBJECT_ID_LENGTH, or greater than org.eclipse.jgit.lfs.lib.Constants#LONG_OBJECT_ID_LENGTH.
getFirstByteback to summary
public final int getFirstByte()

Get the first 8 bits of the LongObjectId. This is a faster version of getByte(0).

Returns:int

a discriminator usable for a fan-out style map. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].

getNameback to summary
public final String getName()

Get string form of the SHA-256

Returns:String

string form of the SHA-256, in lower case hexadecimal.

getSecondByteback to summary
public final int getSecondByte()

Get the second 8 bits of the LongObjectId.

Returns:int

a discriminator usable for a fan-out style map. Returned values are unsigned and thus are in the range [0,255] rather than the signed byte range of [-128, 127].

hashCodeback to summary
public final 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
isEqualback to summary
public static boolean isEqual(final AnyLongObjectId firstObjectId, final AnyLongObjectId secondObjectId)

Compare two object identifier byte sequences for equality.

Parameters
firstObjectId:AnyLongObjectId

the first identifier to compare. Must not be null.

secondObjectId:AnyLongObjectId

the second identifier to compare. Must not be null.

Returns:boolean

true if the two identifiers are the same.

Since
5.4
nameback to summary
public final String name()

Get string form of the SHA-256

Returns:String

string form of the SHA-256, in lower case hexadecimal.

startsWithback to summary
public boolean startsWith(AbbreviatedLongObjectId abbr)

Tests if this LongObjectId starts with the given abbreviation.

Parameters
abbr:AbbreviatedLongObjectId

the abbreviation.

Returns:boolean

true if this LongObjectId begins with the abbreviation; else false.

toHexByteArrayback to summary
private byte[] toHexByteArray()
toHexCharArrayback to summary
pack-priv char[] toHexCharArray()
toHexCharArrayback to summary
private void toHexCharArray(char[] dst)
toObjectIdback to summary
public abstract LongObjectId toObjectId()

Obtain an immutable copy of this current object.

See copy() if this is a possibly subclassed (but immutable) identity and the application needs a lightweight identity only reference.

Returns:LongObjectId

an immutable copy. May be this if this is already an immutable instance.

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
writeRawLongback to summary
private static void writeRawLong(OutputStream w, long v) throws IOException