Enum Class CrcAlgorithmConfig

java.lang.Object
java.lang.Enum<CrcAlgorithmConfig>
org.refcodes.numerical.CrcAlgorithmConfig
All Implemented Interfaces:
Serializable, Comparable<CrcAlgorithmConfig>, Constable, org.refcodes.mixin.NameAccessor, CrcAlgorithm, CrcWidthAccessor

public enum CrcAlgorithmConfig extends Enum<CrcAlgorithmConfig> implements CrcAlgorithm
Enumeration with CRC implementations hacked together from sources "out there".
  • Enum Constant Details

  • Method Details

    • values

      public static CrcAlgorithmConfig[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CrcAlgorithmConfig valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toCrcChecksum

      public long toCrcChecksum(byte aData)
      Calculates the according checksum from the supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      Returns:
      The according checksum.
    • getName

      public String getName()
      Specified by:
      getName in interface org.refcodes.mixin.NameAccessor
    • getCrcWidth

      public int getCrcWidth()
      Retrieves the value from the CRC byte width (number of bytes used to store a CRC checksum) property.
      Specified by:
      getCrcWidth in interface CrcWidthAccessor
      Returns:
      The name stored by the CRC byte width (number of bytes used to store a CRC checksum) property.
    • toCrcChecksum

      public long toCrcChecksum(long aCrc, byte aData)
      Updates the according checksum with he supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      Returns:
      The accordingly updated checksum.
    • toCrcChecksum

      public long toCrcChecksum(byte[] aData)
      Calculates the according checksum from the supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      Returns:
      The according checksum.
    • toCrcChecksum

      public long toCrcChecksum(long aCrc, byte[] aData)
      Updates the according checksum with he supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      Returns:
      The accordingly updated checksum.
    • toCrcChecksum

      public long toCrcChecksum(byte[] aData, int aOffset, int aLength)
      Calculates the according checksum from the supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      aOffset - The offset from where to start.
      aLength - The number of bytes to cover.
      Returns:
      The according checksum.
    • toCrcChecksum

      public long toCrcChecksum(long aCrc, byte[] aData, int aOffset, int aLength)
      Updates the according checksum with he supplied data.
      Specified by:
      toCrcChecksum in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      aOffset - The offset from where to start.
      aLength - The number of bytes to cover.
      Returns:
      The accordingly updated checksum.
    • toCrcBytes

      public byte[] toCrcBytes(byte aData, Endianess aEndianess)
      Calculates the according checksum from the supplied data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The according checksum.
    • toCrcBytes

      public byte[] toCrcBytes(long aCrc, byte aData, Endianess aEndianess)
      Updates the according checksum with he supplied data data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The accordingly updated checksum.
    • toCrcBytes

      public byte[] toCrcBytes(byte[] aData, Endianess aEndianess)
      Calculates the according checksum from the supplied data data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The according checksum.
    • toCrcBytes

      public byte[] toCrcBytes(long aCrc, byte[] aData, Endianess aEndianess)
      Updates the according checksum with he supplied data data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The accordingly updated checksum.
    • toCrcBytes

      public byte[] toCrcBytes(byte[] aData, int aOffset, int aLength, Endianess aEndianess)
      Calculates the according checksum from the supplied data data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aData - The data for which to calculate the checksum.
      aOffset - The offset from where to start.
      aLength - The number of bytes to cover.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The according checksum.
    • toCrcBytes

      public byte[] toCrcBytes(long aCrc, byte[] aData, int aOffset, int aLength, Endianess aEndianess)
      Updates the according checksum with he supplied data data and returns the according byte array of the CRC checksum.
      Specified by:
      toCrcBytes in interface CrcAlgorithm
      Parameters:
      aCrc - The CRC checksum to be updated.
      aData - The data for which to calculate the checksum.
      aOffset - The offset from where to start.
      aLength - The number of bytes to cover.
      aEndianess - The Endianess (big endian or little endian) of the resulting bytes representing the CRC checksum.
      Returns:
      The accordingly updated checksum.
    • getCrcSize

      public CrcSize getCrcSize()
      Gets the CrcSize class to which this CrcAlgorithm belongs.
      Specified by:
      getCrcSize in interface CrcAlgorithm
      Returns:
      The CrcSize enumeration providing various width related methods.
    • toString

      public String toString()
      Overrides:
      toString in class Enum<CrcAlgorithmConfig>