java.lang.Object
com.inductiveautomation.ignition.common.util.CRCUtil

public class CRCUtil extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    calcCRC(byte[] arr)
    Calculates a CRC for the byte array.
    static long
    calcCRC(File file)
    Calculates the CRC of a file.
    static <T> long
    crc(Collection<T> items)
    This is a convenience method that will use whatever T.hashCode() happens to be as the hash code.
    static <T> long
    crc(Collection<T> items, CRCUtil.HashCoder<T> hashCoder)
    Calculates a reliably unique code for a given Collection<T> that is indifferent to the collections lack of order.

    Methods inherited from class java.lang.Object

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

    • CRCUtil

      public CRCUtil()
  • Method Details

    • calcCRC

      public static long calcCRC(byte[] arr)
      Calculates a CRC for the byte array. If the array is null or has length==0, returns 0.
    • calcCRC

      public static long calcCRC(File file) throws IOException
      Calculates the CRC of a file. Avoids loading the whole file into memory
      Throws:
      IOException
    • crc

      public static <T> long crc(Collection<T> items)
      This is a convenience method that will use whatever T.hashCode() happens to be as the hash code.
      See Also:
    • crc

      public static <T> long crc(Collection<T> items, CRCUtil.HashCoder<T> hashCoder)
      Calculates a reliably unique code for a given Collection<T> that is indifferent to the collections lack of order.
      Parameters:
      items - The Collection<T> you want a CRC for.
      hashCoder - The HashCoder that provides a hashCode for an object of T.
      Returns:
      A CRC for the given Collection<T>.