com.judoscript.util
Class Roman

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by com.judoscript.util.Roman
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Roman
extends java.text.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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
java.text.NumberFormat.Field
 
Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
Roman()
           
 
Method Summary
 java.lang.StringBuffer format(double n, java.lang.StringBuffer a, java.text.FieldPosition p)
           
 java.lang.StringBuffer format(long n, java.lang.StringBuffer s, java.text.FieldPosition p)
          This method converts the supplied long into capitalised Roman numerals.
BUG: the method does not take account of the FieldPosition p parameter.
 java.lang.Number parse(java.lang.String text, java.text.ParsePosition parsePosition)
          This method converts a Roman Numeral string to a long integer.
static long toLong(java.lang.String s)
          This method converts a Roman Numeral string to a long integer.
static java.lang.String toRoman(long n)
          This method converts a long integer to capitalised Roman notation.
 
Methods inherited from class java.text.NumberFormat
clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Roman

public Roman()
Method Detail

format

public java.lang.StringBuffer format(double n,
                                     java.lang.StringBuffer a,
                                     java.text.FieldPosition p)
Specified by:
format in class java.text.NumberFormat

parse

public java.lang.Number parse(java.lang.String text,
                              java.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.

Specified by:
parse in class java.text.NumberFormat
Parameters:
s - string of Roman Numerals
parsePosition - the place to start parsing
Returns:
A Long object containing the parsed Roman numeral

toLong

public static long toLong(java.lang.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 java.lang.StringBuffer format(long n,
                                     java.lang.StringBuffer s,
                                     java.text.FieldPosition p)
This method converts the supplied long into capitalised Roman numerals.
BUG: the method does not take account of the FieldPosition p parameter.

Specified by:
format in class java.text.NumberFormat
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

toRoman

public static java.lang.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.