java.lang.Object
kala.compress.archivers.zip.ZipEightByteInteger
- All Implemented Interfaces:
Serializable
Utility class that represents an eight byte integer with conversion rules for the little-endian byte order of ZIP files.
- Since:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intThe number of bytes used to represent an instance in binary form.private static final BigIntegerprivate static final longprivate final longThe value is treated as unsigned.static final ZipEightByteIntegerConstant for a value of zero. -
Constructor Summary
ConstructorsConstructorDescriptionZipEightByteInteger(byte[] bytes) Constructs a new instance from bytes.ZipEightByteInteger(byte[] bytes, int offset) Constructs a new instance from the eight bytes starting at offset.ZipEightByteInteger(long value) Constructs a new instance from a number.ZipEightByteInteger(BigInteger value) Constructs a new instance from a number. -
Method Summary
Modifier and TypeMethodDescriptionbooleanOverride to make two instances with same value equal.byte[]getBytes()Gets value as eight bytes in big-endian byte order.static byte[]getBytes(long value) Gets value as eight bytes in big-endian byte order.static byte[]getBytes(BigInteger value) Gets value as eight bytes in big-endian byte order.longGets value as Java long.static longgetLongValue(byte[] bytes) Gets the value as a Java long from an eight-byte array.static longgetLongValue(byte[] bytes, int offset) Gets the value as a Java long from eight bytes starting at given array offset.getValue()Gets value as Java BigInteger.static BigIntegergetValue(byte[] bytes) Gets the value as a Java long from an eight-byte array.static BigIntegergetValue(byte[] bytes, int offset) Gets the value as a Java BigInteger from eight bytes starting at given array offset.inthashCode()Override to make two instances with same value equal.toString()(package private) static BigIntegertoUnsignedBigInteger(long value) package private for tests only.
-
Field Details
-
BYTES
static final int BYTESThe number of bytes used to represent an instance in binary form.- See Also:
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ZERO
Constant for a value of zero. -
HIGHEST_BIT
-
value
private final long valueThe value is treated as unsigned.
-
-
Constructor Details
-
ZipEightByteInteger
Constructs a new instance from a number.- Parameters:
value- the BigInteger to store as a ZipEightByteInteger
-
ZipEightByteInteger
public ZipEightByteInteger(byte[] bytes) Constructs a new instance from bytes.- Parameters:
bytes- the bytes to store as a ZipEightByteInteger.
-
ZipEightByteInteger
public ZipEightByteInteger(byte[] bytes, int offset) Constructs a new instance from the eight bytes starting at offset.- Parameters:
bytes- the bytes to store as a ZipEightByteInteger.offset- the offset to start.
-
ZipEightByteInteger
public ZipEightByteInteger(long value) Constructs a new instance from a number.- Parameters:
value- the long to store as a ZipEightByteInteger.
-
-
Method Details
-
getBytes
Gets value as eight bytes in big-endian byte order.- Parameters:
value- the value to convert.- Returns:
- value as eight bytes in big-endian byte order.
-
getBytes
public static byte[] getBytes(long value) Gets value as eight bytes in big-endian byte order.- Parameters:
value- the value to convert.- Returns:
- value as eight bytes in big-endian byte order.
-
getLongValue
public static long getLongValue(byte[] bytes) Gets the value as a Java long from an eight-byte array.- Parameters:
bytes- the array of bytes.- Returns:
- the corresponding Java long value.
-
getLongValue
public static long getLongValue(byte[] bytes, int offset) Gets the value as a Java long from eight bytes starting at given array offset.- Parameters:
bytes- the array of bytes.offset- the offset to start.- Returns:
- the corresponding Java long value.
-
getValue
Gets the value as a Java long from an eight-byte array.- Parameters:
bytes- the array of bytes.- Returns:
- the corresponding Java BigInteger value.
-
getValue
Gets the value as a Java BigInteger from eight bytes starting at given array offset.- Parameters:
bytes- the array of bytes.offset- the offset to start.- Returns:
- the corresponding Java BigInteger value.
-
toUnsignedBigInteger
package private for tests only. -
equals
Override to make two instances with same value equal. -
getBytes
public byte[] getBytes()Gets value as eight bytes in big-endian byte order.- Returns:
- value as eight bytes in big-endian order.
-
getLongValue
public long getLongValue()Gets value as Java long.- Returns:
- value as a long.
-
getValue
Gets value as Java BigInteger.- Returns:
- value as a BigInteger.
-
hashCode
public int hashCode()Override to make two instances with same value equal. -
toString
-