Package apg
Class UdtLib.DecNum
- java.lang.Object
-
- apg.Parser.UdtCallback
-
- apg.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 thanmax
decimal digits, where0 <= min <= max
. A decimal digit is0-9
.
-
-
Field Summary
-
Fields inherited from class apg.Parser.UdtCallback
callbackData
-
-
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.
-
-
-
Constructor Detail
-
DecNum
public DecNum(Parser p)
The default constructor.The default values are
min = 0, max = infinite
. Note thatmin = 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 andmin = 0
, if falsemin = 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 classParser.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 range0 <= L <=(n-1)
, wheren
is the remaining number of characters in the input string.
-
-