Package apg

Class UdtLib.DecNum

  • Enclosing class:
    UdtLib

    public static class UdtLib.DecNum
    extends Parser.UdtCallback
    UDT for a decimal number.

    This is a string of at least min and not more than max decimal digits, where 0 <= min <= max. A decimal digit is 0-9.

    • Constructor Summary

      Constructors 
      Constructor Description
      DecNum​(Parser p)
      The default constructor.
      DecNum​(Parser p, boolean optional)
      Constructor with choice for whether the number is optional or not.
      DecNum​(Parser p, int minDigits, int maxDigits, boolean leadingZeros)
      Constructor with explicit choices for all options.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int callback​(int offset)
      The UDT function.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DecNum

        public DecNum​(Parser p)
        The default constructor.

        The default values are min = 0, max = infinite. Note that min = 0, indicates that the decimal number phrase is optional. Leading zeros are not allowed.

        Parameters:
        p - the Parser object this UDT is attached to.
      • DecNum

        public DecNum​(Parser p,
                      boolean optional)
        Constructor with choice for whether the number is optional or not. Leading zeros are not allowed.
        Parameters:
        p - the Parser object this UDT is attached to.
        optional - if true, the number is optional and min = 0, if false min = 1. For both, max = infinite and leading zeros are not allowed.
      • DecNum

        public DecNum​(Parser p,
                      int minDigits,
                      int maxDigits,
                      boolean leadingZeros)
        Constructor with explicit choices for all options.
        Parameters:
        p - the Parser object this UDT is attached to.
        minDigits - minimum number of digits allowed (must be >= 0)
        maxDigits - maximum number of digits allowed (must be >= minDigits)
        leadingZeros - if true, leading zeros are allowed, if false, leading zeros are not allowed.
    • Method Detail

      • callback

        public int callback​(int offset)
        Description copied from class: Parser.UdtCallback
        The UDT function.
        Specified by:
        callback in class Parser.UdtCallback
        Parameters:
        offset - offset into the input string to the first character of the parsed phrase.
        Returns:
        the matched phrase length, L, or -1 if no phrase was matched. The phrase length must be in the range 0 <= L <=(n-1), where n is the remaining number of characters in the input string.