Package 

Class ZipShort

  • All Implemented Interfaces:
    java.io.Serializable , java.lang.Cloneable

    
    public final class ZipShort
     implements Cloneable, Serializable
                        

    Utility class that represents a two byte integer with conversion rules for the little endian byte order of ZIP files.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static ZipShort ZERO
      private final int value
    • Constructor Summary

      Constructors 
      Constructor Description
      ZipShort(Array<byte> bytes) Create instance from bytes.
      ZipShort(Array<byte> bytes, int offset) Create instance from the two bytes starting at offset.
      ZipShort(int value) Create instance from a number.
    • Method Summary

      Modifier and Type Method Description
      static int getValue(Array<byte> bytes) Helper method to get the value as a java int from a two-byte array
      static int getValue(Array<byte> bytes) Helper method to get the value as a java int from a two-byte array
      static Array<byte> getBytes(int value) Get value as two bytes in big endian byte order.
      static void putShort(int value, Array<byte> buf, int offset) put the value as two bytes in big endian byte order.
      Object clone()
      boolean equals(Object o) Override to make two instances with same value equal.
      Array<byte> getBytes() Get value as two bytes in big endian byte order.
      int hashCode() Override to make two instances with same value equal.
      String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ZipShort

        ZipShort(Array<byte> bytes)
        Create instance from bytes.
        Parameters:
        bytes - the bytes to store as a ZipShort
      • ZipShort

        ZipShort(Array<byte> bytes, int offset)
        Create instance from the two bytes starting at offset.
        Parameters:
        bytes - the bytes to store as a ZipShort
        offset - the offset to start
      • ZipShort

        ZipShort(int value)
        Create instance from a number.
        Parameters:
        value - the int to store as a ZipShort
    • Method Detail

      • getValue

         static int getValue(Array<byte> bytes)

        Helper method to get the value as a java int from a two-byte array

        Parameters:
        bytes - the array of bytes
      • getValue

         static int getValue(Array<byte> bytes)

        Helper method to get the value as a java int from a two-byte array

        Parameters:
        bytes - the array of bytes
      • getBytes

         static Array<byte> getBytes(int value)

        Get value as two bytes in big endian byte order.

        Parameters:
        value - the Java int to convert to bytes
      • putShort

         static void putShort(int value, Array<byte> buf, int offset)

        put the value as two bytes in big endian byte order.

        Parameters:
        value - the Java int to convert to bytes
        buf - the output buffer
        offset - The offset within the output buffer of the first byte to be written.
      • equals

         boolean equals(Object o)

        Override to make two instances with same value equal.

        Parameters:
        o - an object to compare
      • getBytes

         Array<byte> getBytes()

        Get value as two bytes in big endian byte order.

      • hashCode

         int hashCode()

        Override to make two instances with same value equal.