Package org.apache.tools.zip
Class ZipEightByteInteger
java.lang.Object
org.apache.tools.zip.ZipEightByteInteger
Utility class that represents an eight byte integer with conversion
rules for the big endian byte order of ZIP files.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionZipEightByteInteger(byte[] bytes) Create instance from bytes.ZipEightByteInteger(byte[] bytes, int offset) Create instance from the eight bytes starting at offset.ZipEightByteInteger(long value) Create instance from a number.ZipEightByteInteger(BigInteger value) Create instance from a number. -
Method Summary
Modifier and TypeMethodDescriptionbooleanOverride to make two instances with same value equal.byte[]getBytes()Get value as eight bytes in big endian byte order.static byte[]getBytes(long value) Get value as eight bytes in big endian byte order.static byte[]getBytes(BigInteger value) Get value as eight bytes in big endian byte order.longGet value as Java long.static longgetLongValue(byte[] bytes) Helper method to get the value as a Java long from an eight-byte arraystatic longgetLongValue(byte[] bytes, int offset) Helper method to get the value as a Java long from eight bytes starting at given array offsetgetValue()Get value as Java long.static BigIntegergetValue(byte[] bytes) Helper method to get the value as a Java long from an eight-byte arraystatic BigIntegergetValue(byte[] bytes, int offset) Helper method to get the value as a Java BigInteger from eight bytes starting at given array offsetinthashCode()Override to make two instances with same value equal.toString()
-
Field Details
-
ZERO
-
-
Constructor Details
-
ZipEightByteInteger
public ZipEightByteInteger(long value) Create instance from a number.- Parameters:
value- the long to store as a ZipEightByteInteger
-
ZipEightByteInteger
Create instance from a number.- Parameters:
value- the BigInteger to store as a ZipEightByteInteger
-
ZipEightByteInteger
public ZipEightByteInteger(byte[] bytes) Create instance from bytes.- Parameters:
bytes- the bytes to store as a ZipEightByteInteger
-
ZipEightByteInteger
public ZipEightByteInteger(byte[] bytes, int offset) Create instance from the eight bytes starting at offset.- Parameters:
bytes- the bytes to store as a ZipEightByteIntegeroffset- the offset to start
-
-
Method Details
-
getBytes
public byte[] getBytes()Get value as eight bytes in big endian byte order.- Returns:
- value as eight bytes in big endian order
-
getLongValue
public long getLongValue()Get value as Java long.- Returns:
- value as a long
-
getValue
Get value as Java long.- Returns:
- value as a long
-
getBytes
public static byte[] getBytes(long value) Get 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
Get 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, int offset) Helper method to get the value as a Java long from eight bytes starting at given array offset- Parameters:
bytes- the array of bytesoffset- the offset to start- Returns:
- the corresponding Java long value
-
getValue
Helper method to get the value as a Java BigInteger from eight bytes starting at given array offset- Parameters:
bytes- the array of bytesoffset- the offset to start- Returns:
- the corresponding Java BigInteger value
-
getLongValue
public static long getLongValue(byte[] bytes) Helper method to get the value as a Java long from an eight-byte array- Parameters:
bytes- the array of bytes- Returns:
- the corresponding Java long value
-
getValue
Helper method to get the value as a Java long from an eight-byte array- Parameters:
bytes- the array of bytes- Returns:
- the corresponding Java BigInteger value
-
equals
Override to make two instances with same value equal. -
hashCode
public int hashCode()Override to make two instances with same value equal. -
toString
-