Class ZipEightByteInteger
- java.lang.Object
-
- org.apache.commons.compress.archivers.zip.ZipEightByteInteger
-
- All Implemented Interfaces:
java.io.Serializable
public final class ZipEightByteInteger extends java.lang.Object implements java.io.SerializableUtility class that represents an eight byte integer with conversion rules for the little endian byte order of ZIP files.- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intBYTE_1private static intBYTE_1_MASKprivate static intBYTE_1_SHIFTprivate static intBYTE_2private static intBYTE_2_MASKprivate static intBYTE_2_SHIFTprivate static intBYTE_3private static longBYTE_3_MASKprivate static intBYTE_3_SHIFTprivate static intBYTE_4private static longBYTE_4_MASKprivate static intBYTE_4_SHIFTprivate static intBYTE_5private static longBYTE_5_MASKprivate static intBYTE_5_SHIFTprivate static intBYTE_6private static longBYTE_6_MASKprivate static intBYTE_6_SHIFTprivate static intBYTE_7private static longBYTE_7_MASKprivate static intBYTE_7_SHIFTprivate static byteLEFTMOST_BITprivate static intLEFTMOST_BIT_SHIFTprivate static longserialVersionUIDprivate java.math.BigIntegervaluestatic ZipEightByteIntegerZERO
-
Constructor Summary
Constructors Constructor Description ZipEightByteInteger(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(java.math.BigInteger value)Create instance from a number.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Override 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(java.math.BigInteger value)Get value as eight bytes in big endian byte order.longgetLongValue()Get 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 offsetjava.math.BigIntegergetValue()Get value as Java BigInteger.static java.math.BigIntegergetValue(byte[] bytes)Helper method to get the value as a Java long from an eight-byte arraystatic java.math.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.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
BYTE_1
private static final int BYTE_1
- See Also:
- Constant Field Values
-
BYTE_1_MASK
private static final int BYTE_1_MASK
- See Also:
- Constant Field Values
-
BYTE_1_SHIFT
private static final int BYTE_1_SHIFT
- See Also:
- Constant Field Values
-
BYTE_2
private static final int BYTE_2
- See Also:
- Constant Field Values
-
BYTE_2_MASK
private static final int BYTE_2_MASK
- See Also:
- Constant Field Values
-
BYTE_2_SHIFT
private static final int BYTE_2_SHIFT
- See Also:
- Constant Field Values
-
BYTE_3
private static final int BYTE_3
- See Also:
- Constant Field Values
-
BYTE_3_MASK
private static final long BYTE_3_MASK
- See Also:
- Constant Field Values
-
BYTE_3_SHIFT
private static final int BYTE_3_SHIFT
- See Also:
- Constant Field Values
-
BYTE_4
private static final int BYTE_4
- See Also:
- Constant Field Values
-
BYTE_4_MASK
private static final long BYTE_4_MASK
- See Also:
- Constant Field Values
-
BYTE_4_SHIFT
private static final int BYTE_4_SHIFT
- See Also:
- Constant Field Values
-
BYTE_5
private static final int BYTE_5
- See Also:
- Constant Field Values
-
BYTE_5_MASK
private static final long BYTE_5_MASK
- See Also:
- Constant Field Values
-
BYTE_5_SHIFT
private static final int BYTE_5_SHIFT
- See Also:
- Constant Field Values
-
BYTE_6
private static final int BYTE_6
- See Also:
- Constant Field Values
-
BYTE_6_MASK
private static final long BYTE_6_MASK
- See Also:
- Constant Field Values
-
BYTE_6_SHIFT
private static final int BYTE_6_SHIFT
- See Also:
- Constant Field Values
-
BYTE_7
private static final int BYTE_7
- See Also:
- Constant Field Values
-
BYTE_7_MASK
private static final long BYTE_7_MASK
- See Also:
- Constant Field Values
-
BYTE_7_SHIFT
private static final int BYTE_7_SHIFT
- See Also:
- Constant Field Values
-
LEFTMOST_BIT_SHIFT
private static final int LEFTMOST_BIT_SHIFT
- See Also:
- Constant Field Values
-
LEFTMOST_BIT
private static final byte LEFTMOST_BIT
- See Also:
- Constant Field Values
-
value
private final java.math.BigInteger value
-
ZERO
public static final ZipEightByteInteger ZERO
-
-
Constructor Detail
-
ZipEightByteInteger
public ZipEightByteInteger(long value)
Create instance from a number.- Parameters:
value- the long to store as a ZipEightByteInteger
-
ZipEightByteInteger
public ZipEightByteInteger(java.math.BigInteger value)
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 Detail
-
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
public java.math.BigInteger getValue()
Get value as Java BigInteger.- Returns:
- value as a BigInteger
-
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
public static byte[] getBytes(java.math.BigInteger 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
-
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
public static java.math.BigInteger getValue(byte[] bytes, int offset)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
public static java.math.BigInteger getValue(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 BigInteger value
-
equals
public boolean equals(java.lang.Object o)
Override to make two instances with same value equal.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- an object to compare- Returns:
- true if the objects are equal
-
hashCode
public int hashCode()
Override to make two instances with same value equal.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashCode of the value stored in the ZipEightByteInteger
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-