edu.northwestern.at.utils

## Class RomanNumeralUtils

- java.lang.Object
- - edu.northwestern.at.utils.RomanNumeralUtils

-     public class RomanNumeralUtils
      extends java.lang.Object

  Roman numeral utilities.

  This static class provides various utility methods for working with Roman numerals. The range of values supported is 1 through 5000 .

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.util.Map<java.lang.Integer,java.lang.String>` | `integerToRomanMap` Integer to Roman numerals map for 1 - 5000 .
    `protected static int[]` | `integerValues` Integer values for entries in "romanNumerals".
    `static java.lang.String` | `looseOrdinalRomanNumeralPattern` Ordinal Roman numeral pattern.
    `protected static java.lang.String` | `looseRomanNumeralPattern` Regular expression pattern matching a looser Roman numeral.
    `protected static int` | `MAX_ROMAN_NUMERAL` Maximum Roman Numeral value handled here.
    `protected static java.lang.String` | `romanNumeralPattern` Regular expression pattern matching a Roman numeral.
    `protected static java.lang.String[]` | `romanNumerals` Roman numeral strings.
    `protected static java.util.Map<java.lang.String,java.lang.Integer>` | `romanToIntegerMap` Roman numerals to integer map for 1 - 5000 .

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RomanNumeralUtils()` Don't allow instantiation, do allow overrides.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static java.lang.String` | `integerToRoman(int n)` Convert integer to a Roman numeral.
    `static java.lang.String` | `integerToRomanNumerals(int i)` Convert integer to a Roman numeral.
    `static boolean` | `isLooseOrdinalRomanNumeral(java.lang.String s)` See if string is an ordinal Roman numeral using looser definition.
    `static boolean` | `isLooseRomanNumeral(java.lang.String s)` See if string is a Roman numeral using looser (older) definition.
    `static boolean` | `isRomanNumeral(java.lang.String s)` See if string is a Roman numeral.
    `static int` | `romanNumeralsToInteger(java.lang.String s)` Convert Roman numeral to integer.

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

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

- - ### Field Detail

    - #### MAX_ROMAN_NUMERAL

          protected static final int MAX_ROMAN_NUMERAL

      Maximum Roman Numeral value handled here.
      See Also:
        Constant Field Values

    - #### romanNumeralPattern

          protected static java.lang.String romanNumeralPattern

      Regular expression pattern matching a Roman numeral.

    - #### looseRomanNumeralPattern

          protected static java.lang.String looseRomanNumeralPattern

      Regular expression pattern matching a looser Roman numeral.

    - #### looseOrdinalRomanNumeralPattern

          public static java.lang.String looseOrdinalRomanNumeralPattern

      Ordinal Roman numeral pattern.

    - #### integerToRomanMap

          protected static java.util.Map<java.lang.Integer,java.lang.String> integerToRomanMap

      Integer to Roman numerals map for 1 - 5000 .

    - #### romanToIntegerMap

          protected static java.util.Map<java.lang.String,java.lang.Integer> romanToIntegerMap

      Roman numerals to integer map for 1 - 5000 .

    - #### romanNumerals

          protected static java.lang.String[] romanNumerals

      Roman numeral strings.

    - #### integerValues

          protected static int[] integerValues

      Integer values for entries in "romanNumerals".

  - ### Constructor Detail

    - #### RomanNumeralUtils

          protected RomanNumeralUtils()

      Don't allow instantiation, do allow overrides.

  - ### Method Detail

    - #### isRomanNumeral

          public static boolean isRomanNumeral(java.lang.String s)

      See if string is a Roman numeral.
      Parameters:
        `s` - The string.
      Returns:
        true if string is a valid Roman numeral.

    - #### isLooseRomanNumeral

          public static boolean isLooseRomanNumeral(java.lang.String s)

      See if string is a Roman numeral using looser (older) definition.
      Parameters:
        `s` - The string.
      Returns:
        true if string is a valid Roman numeral using looser (older) definition.

    - #### isLooseOrdinalRomanNumeral

          public static boolean isLooseOrdinalRomanNumeral(java.lang.String s)

      See if string is an ordinal Roman numeral using looser definition.
      Parameters:
        `s` - The string.
      Returns:
        true if string is a valid Roman ordinal numeral using looser (older) definition.

    - #### romanNumeralsToInteger

          public static int romanNumeralsToInteger(java.lang.String s)

      Convert Roman numeral to integer.
      Parameters:
        `s` - The Roman numeral as a string.
      Returns:
        The corresponding decimal integer. -1 if Roman numeral string is bad.

    - #### integerToRomanNumerals

          public static java.lang.String integerToRomanNumerals(int i)

      Convert integer to a Roman numeral.
      Parameters:
        `i` - The integer to convert to a Roman numeral. Must be 1 < i <= 5000 .
      Returns:
        The corresponding Roman numeral as a string. "" if input value is invalid.

    - #### integerToRoman

          protected static java.lang.String integerToRoman(int n)

      Convert integer to a Roman numeral.
      Parameters:
        `n` - The integer to convert to a Roman numeral.
      Returns:
        The corresponding Roman numeral as a string.