Class CRCUtil
- java.lang.Object
-
- com.inductiveautomation.ignition.common.util.CRCUtil
-
public class CRCUtil extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CRCUtil.HashCoder<T>
-
Constructor Summary
Constructors Constructor Description CRCUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
calcCRC(byte[] arr)
Calculates a CRC for the byte array.static long
calcCRC(java.io.File file)
Calculates the CRC of a file.static <T> long
crc(java.util.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(java.util.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.
-
-
-
Method Detail
-
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(java.io.File file) throws java.io.IOException
Calculates the CRC of a file. Avoids loading the whole file into memory- Throws:
java.io.IOException
-
crc
public static <T> long crc(java.util.Collection<T> items)
This is a convenience method that will use whatever T.hashCode() happens to be as the hash code.- See Also:
crc(Collection, HashCoder)
-
crc
public static <T> long crc(java.util.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>.
-
-