public class RomanNumeralUtils
extends java.lang.Object
This static class provides various utility methods for working with Roman numerals. The range of values supported is 1 through 5000 .
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 .
|
Modifier | Constructor and Description |
---|---|
protected |
RomanNumeralUtils()
Don't allow instantiation, do allow overrides.
|
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.
|
protected static final int MAX_ROMAN_NUMERAL
protected static java.lang.String romanNumeralPattern
protected static java.lang.String looseRomanNumeralPattern
public static java.lang.String looseOrdinalRomanNumeralPattern
protected static java.util.Map<java.lang.Integer,java.lang.String> integerToRomanMap
protected static java.util.Map<java.lang.String,java.lang.Integer> romanToIntegerMap
protected static java.lang.String[] romanNumerals
protected static int[] integerValues
protected RomanNumeralUtils()
public static boolean isRomanNumeral(java.lang.String s)
s
- The string.public static boolean isLooseRomanNumeral(java.lang.String s)
s
- The string.public static boolean isLooseOrdinalRomanNumeral(java.lang.String s)
s
- The string.public static int romanNumeralsToInteger(java.lang.String s)
s
- The Roman numeral as a string.public static java.lang.String integerToRomanNumerals(int i)
i
- The integer to convert to a Roman numeral.
Must be 1 < i <= 5000 .protected static java.lang.String integerToRoman(int n)
n
- The integer to convert to a Roman numeral.