fields

## Class CRCField

- java.lang.Object
- - fields.CRCField

- All Implemented Interfaces:
    Field

      public class CRCField
      extends java.lang.Object
      implements Field

  Model for the WM-Bus CRC-Fields
  Author:
    David Hudec (dwdization@gmail.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.Byte[]` | `crc`
    `private static char[]` | `CRC_TABLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CRCField(java.lang.Byte[] bytes)`
    `CRCField(java.util.List<java.lang.Byte> bytes)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static char` | `B013_dnpcrc(char[] buffer)` Performs the CRC-DNP calculation itself.
    `static boolean` | `checkCRC(java.lang.Byte[] aBuffer)` Validates given Byte[ ] against its CRC-DNP, which has to the last two Bytes in the Byte[ ].
    `java.util.List<java.lang.Byte>` | `getBytes()` Fetches all parts of the field and constructs it into a List of Bytes by WM-Bus standard, MSB first.
    `java.util.List<java.lang.Byte>` | `getBytesInTxOrder()` Fetches all parts of the field and constructs it into a List of Bytes by WM-Bus standard, LSB first.
    `static java.lang.Byte[]` | `makeCRC(java.lang.Byte[] aBuffer)` Calculates CRC-DNP of given bytes.
    `static java.lang.Byte` | `oneByteXor(java.lang.Byte[] bytes)`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### crc

          private final java.lang.Byte[] crc

    - #### CRC_TABLE

          private static final char[] CRC_TABLE

  - ### Constructor Detail

    - #### CRCField

          public CRCField(java.lang.Byte[] bytes)

    - #### CRCField

          public CRCField(java.util.List<java.lang.Byte> bytes)

  - ### Method Detail

    - #### B013_dnpcrc

          private static char B013_dnpcrc(char[] buffer)

      Performs the CRC-DNP calculation itself.

    - #### checkCRC

          public static boolean checkCRC(java.lang.Byte[] aBuffer)
                                  throws java.lang.IndexOutOfBoundsException

      Validates given Byte[ ] against its CRC-DNP, which has to the last two Bytes in the Byte[ ].
      Parameters:
        `aBuffer` - Bytes to validate and their CRC-DNP
      Returns:
        true if given Bytes match their CRC-DNP
      Throws:
        `java.lang.IndexOutOfBoundsException` - when the given array is shorter than 3

    - #### getBytes

          public java.util.List<java.lang.Byte> getBytes()

      Description copied from interface: `Field`
      Fetches all parts of the field and constructs it into a List of Bytes by WM-Bus standard, MSB first.
      Specified by:
        `getBytes` in interface `Field`
      Returns:
        List of Bytes representing this field, MSB first

    - #### getBytesInTxOrder

          public java.util.List<java.lang.Byte> getBytesInTxOrder()

      Description copied from interface: `Field`
      Fetches all parts of the field and constructs it into a List of Bytes by WM-Bus standard, LSB first.
      Specified by:
        `getBytesInTxOrder` in interface `Field`
      Returns:
        List of Bytes representing this field, LSB first

    - #### makeCRC

          public static java.lang.Byte[] makeCRC(java.lang.Byte[] aBuffer)

      Calculates CRC-DNP of given bytes.
      Parameters:
        `aBuffer` - bytes to include in the calculation
      Returns:
        resulting CRC-DNP in Byte[ ]

    - #### oneByteXor

          public static java.lang.Byte oneByteXor(java.lang.Byte[] bytes)