org.apache.commons.compress.archivers.zip

## Class ZipEightByteInteger

- java.lang.Object
- - org.apache.commons.compress.archivers.zip.ZipEightByteInteger

- All Implemented Interfaces:
    Serializable

      public final class ZipEightByteInteger
      extends Object
      implements 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:
    Serialized Form
  This class is immutable

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ZipEightByteInteger` | `ZERO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZipEightByteInteger(BigInteger value)` Create instance from a number.
    `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.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(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(BigInteger value)` 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.
    `long` | `getLongValue()` Get value as Java long.
    `static long` | `getLongValue(byte[] bytes)` Helper method to get the value as a Java long from an eight-byte array
    `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
    `BigInteger` | `getValue()` Get value as Java BigInteger.
    `static BigInteger` | `getValue(byte[] bytes)` Helper method to get the value as a Java long from an eight-byte array
    `static BigInteger` | `getValue(byte[] bytes, int offset)` Helper method to get the value as a Java BigInteger from eight bytes starting at given array offset
    `int` | `hashCode()` Override to make two instances with same value equal.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### 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(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 ZipEightByteInteger
        `offset` - 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 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(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 bytes
        `offset` - the offset to start
      Returns:
        the corresponding Java long value

    - #### getValue

          public static 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 bytes
        `offset` - 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 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(Object o)

      Override to make two instances with same value equal.
      Overrides:
        `equals` in class `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:
        `hashCode` in class `Object`
      Returns:
        the hashCode of the value stored in the ZipEightByteInteger

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.