Class IntegerGroup

  • All Implemented Interfaces:
    java.io.Serializable, IClusterable

    public final class IntegerGroup
    extends Group
    A Group that captures integer values (positive and negative whole numbers, not Java ints).
    Author:
    Jonathan Locke
    See Also:
    Serialized Form
    • Constructor Detail

      • IntegerGroup

        public IntegerGroup()
        Constructs an IntegerGroup that parses Strings that match the INTEGER pattern in base 10.
        See Also:
        MetaPattern.INTEGER
      • IntegerGroup

        public IntegerGroup​(MetaPattern pattern)
        Constructs an IntegerGroup that parses Strings that match the given pattern in base 10.
        Parameters:
        pattern - The capturing pattern
      • IntegerGroup

        public IntegerGroup​(MetaPattern pattern,
                            int radix)
        Constructs an IntegerGroup that parses Strings that match the given pattern in the given radix.
        Parameters:
        pattern - The capturing pattern
        radix - The radix to use when parsing captured Strings
    • Method Detail

      • getInt

        public int getInt​(java.util.regex.Matcher matcher)
        Parameters:
        matcher - The matcher
        Returns:
        The value
        See Also:
        getInt(Matcher, int)
      • getInt

        public int getInt​(java.util.regex.Matcher matcher,
                          int defaultValue)
        Gets an int by parsing the String matched by this capturing group. The IntegerGroup's radix is used in the conversion.
        Parameters:
        matcher - The matcher
        defaultValue - The default value to use if this group is omitted because it is optional
        Returns:
        The parsed int value
      • getLong

        public long getLong​(java.util.regex.Matcher matcher)
        Parameters:
        matcher - The matcher
        Returns:
        The value
        See Also:
        getLong(Matcher)
      • getLong

        public long getLong​(java.util.regex.Matcher matcher,
                            long defaultValue)
        Gets a long by parsing the String matched by this capturing group. The IntegerGroup's radix is used in the conversion. parsing radix.
        Parameters:
        defaultValue - The default value to use if this group is omitted because it is optional
        matcher - The matcher
        Returns:
        The parsed long value