All Packages Class Hierarchy This Package Previous Next Index
Class benno.number.Roman
java.lang.Object
|
+----java.text.Format
|
+----java.text.NumberFormat
|
+----benno.number.Roman
- public class Roman
- extends NumberFormat
This NumberFormat converts long integers to and from Roman Numeral notation.
Once an instance has been created, the format and parse methods may be used
as defined in java.text.NumberFormat.
The
RomanNumeralConverter
applet demonstrates the use of this class.
- Version:
- $Revision: 1.11 $
- Author:
- Ben Clifford
- See Also:
- RomanNumeralConverter
-
syms
- This table maps individual Roman symbols onto their numerical
values.
Unfortunately, JavaDoc JDK 1.1 does not create documentation
for the inner class Roman.SymTab, so the reader
cannot see the definition.
-
Roman()
-
-
format(double, StringBuffer, FieldPosition)
- This method returns null.
-
format(long, StringBuffer, FieldPosition)
- This method converts the supplied long into capitalised Roman
numerals.
BUG: the method does not take account of the
FieldPosition p
parameter.
-
parse(String, ParsePosition)
- This method converts a Roman Numeral string to a long integer.
-
toLong(String)
- This method converts a Roman Numeral string to a long integer.
-
toRoman(long)
- This method converts a long integer to capitalised Roman notation.
syms
public static Roman. SymTab syms[]
- This table maps individual Roman symbols onto their numerical
values.
Unfortunately, JavaDoc JDK 1.1 does not create documentation
for the inner class Roman.SymTab, so the reader
cannot see the definition.
Roman
public Roman()
format
public StringBuffer format(double n,
StringBuffer a,
FieldPosition p)
- This method returns null. I have found no meaningful translation
of floating point numbers to Roman numerals, however the NumberFormat
method requires that it is implemented. Perhaps should just cast
the double to a long and format accordingly.
- Overrides:
- format in class NumberFormat
parse
public Number parse(String text,
ParsePosition parsePosition)
- This method converts a Roman Numeral string to a long integer. It does
not check that the string is in the correct format - for some incorrectly
formatted numbers, i.e. iix, it will produce a number. For others,
it will throw an exception.
- Parameters:
- s - string of Roman Numerals
- parsePosition - the place to start parsing
- Returns:
- A Long object containing the parsed Roman numeral
- Overrides:
- parse in class NumberFormat
toLong
public static long toLong(String s)
- This method converts a Roman Numeral string to a long integer. It does
not check that the string is in the correct format - for some incorrectly
formatted numbers, i.e. iix, it will produce a number. For others,
it will throw an exception.
- Parameters:
- s - string of Roman Numerals
- Returns:
- The integer representation of the Numerals
format
public StringBuffer format(long n,
StringBuffer s,
FieldPosition p)
- This method converts the supplied long into capitalised Roman
numerals.
BUG: the method does not take account of the
FieldPosition p
parameter.
- Parameters:
- n - The number to be converted into Roman numerals
- s - The StringBuffer into which the output is to be placed.
- Returns:
- The StringBuffer s
- Overrides:
- format in class NumberFormat
toRoman
public static String toRoman(long n)
- This method converts a long integer to capitalised Roman notation.
- Parameters:
- n - The integer to convert to Roman Numerals.
- Returns:
- A String object containing the Roman Numerals.
All Packages Class Hierarchy This Package Previous Next Index