Package com.globalmentor.text
Class RomanNumerals
java.lang.Object
com.globalmentor.text.RomanNumerals
Utilities for working with Roman numerals.
Integers are used to represent Roman numerals. As a Java integer is 32 bits long, a string would need over two million Roman numeral 'M's to surpass this limit.
Conversion algoritms inspired from "When in Rome...." by Jonathan Knudsen at http://java.oreilly.com/bite-size/java_0698.html.
- Author:
- Garret Wilson
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getValue
(char c) Returns the value of the given Roman numeral character.static int
parseRomanNumerals
(String romanNumerals) Parses the given Roman numerals and returns their integer value.
-
Constructor Details
-
RomanNumerals
public RomanNumerals()Default constructor.
-
-
Method Details
-
getValue
public static int getValue(char c) Returns the value of the given Roman numeral character.- Parameters:
c
- The character containing a Roman numeral character.- Returns:
- The value of the given Roman numeral character, or -1 if the character isn't recognized.
-
parseRomanNumerals
Parses the given Roman numerals and returns their integer value.- Parameters:
romanNumerals
- The characters representing the Roman numerals.- Returns:
- The value of the Roman numerals.
- Throws:
NumberFormatException
- Thrown if the given string does not contain a valid Roman numeral value.
-