Class CheckSumTerm

  • All Implemented Interfaces:
    Comparable<IIRVVectorTerm<?>>

    public class CheckSumTerm
    extends LongValuedIIRVTerm
    Three-character checksum to validate message.

    Calculated by summing the decimal equivalent of the preceding characters in the line, counting spaces as 0 and negative signs as 1:

    • 0 through 9 = face value
    • Minus (-) = 1
    • ASCII Space = 0

    Valid Values: 000-999

    Since:
    13.0
    Author:
    Nick LaFarge
    • Field Detail

      • CHECK_SUM_TERM_LENGTH

        public static final int CHECK_SUM_TERM_LENGTH
        The length of the IIRV term within the message.
        See Also:
        Constant Field Values
      • CHECK_SUM_TERM_PATTERN

        public static final String CHECK_SUM_TERM_PATTERN
        Regular expression that ensures the validity of string values for this term.
        See Also:
        Constant Field Values
    • Method Detail

      • fromIIRVTerms

        public static CheckSumTerm fromIIRVTerms​(IIRVVectorTerm<?>... terms)
        Constructs an IIRV checksum from a series of IIRVTerm instances.
        Parameters:
        terms - IIRVTerms to compute checksum
        Returns:
        newly created CheckSum instance
      • computeChecksum

        public static int computeChecksum​(String input)
        Computes the sum of the decimal equivalent of characters in the line, counting spaces as 0 and negative signs as 1.
        Parameters:
        input - input string to compute checksum from
        Returns:
        computed checksum integer value
      • validateLineCheckSum

        public static boolean validateLineCheckSum​(String line)
        Validate a line's embedded checksum value.
        Parameters:
        line - string line of an IIRV message (including checksum as the final three characters)
        Returns:
        true if the derived and embedded checksum values are equal
      • validateAgainstLineString

        public boolean validateAgainstLineString​(String line)
        Validate the checksum from a line based on the object's checksum integer value.
        Parameters:
        line - string line of an IIRV message (including checksum as the final three characters)
        Returns:
        true if the extracted checksum value matches this object's integer value