All Packages Class Hierarchy This Package Previous Next Index
Class org.mitre.tjt.text.AlphaNumberFormat
org.mitre.tjt.text.AlphaNumberFormat
- public class AlphaNumberFormat
This class implements a NumberFormat that generates an alphabetic sequence
that represents the integer value provided.
- Author:
- Tim Taylor
-
AlphaNumberFormat(boolean)
- Creates a new AlphaNumberFormat object.
-
format(double, StringBuffer, FieldPosition)
- Formats the provided double as an alphabetic sequence by converting to a
long.
-
format(long, StringBuffer, FieldPosition)
- Formats the provided long as an alphabetic sequence.
-
main(String[])
- This method is for testing the class.
-
parse(String, ParsePosition)
- Parses a string containing a number expressed as an alphabetic sequence
and converts it to a
Number
.
AlphaNumberFormat
public AlphaNumberFormat(boolean upperCase)
- Creates a new AlphaNumberFormat object. The formats generated by this
object will use uppercase letters if
upperCase
is true,
lower case otherwise.
- Parameters:
- upperCase - True if the format methods should use upper case
letters, (ie: ABC). If false, lowercase letters will be used.
format
public StringBuffer format(double number,
StringBuffer result,
FieldPosition fieldPosition)
- Formats the provided double as an alphabetic sequence by converting to a
long. Loss of precision may result, however, these alphabetic sequence
doesn't have fractions.
- Parameters:
- number - The number to format as an alphabetic sequence.
- result - The StringBuffer to write the formated number to.
- fieldPosition - The field position in the result.
- Returns:
- The StringBuffer provided in
result
with the
formated value of number
appended.
format
public StringBuffer format(long number,
StringBuffer result,
FieldPosition fieldPosition)
- Formats the provided long as an alphabetic sequence.
- Parameters:
- number - The number to format as an alphabetic sequence.
- result - The StringBuffer to write the formated number to.
- fieldPosition - The field position in the result.
- Returns:
- The StringBuffer provided in
result
with the
formated value of number
appended.
parse
public Number parse(String text,
ParsePosition parsePosition)
- Parses a string containing a number expressed as an alphabetic sequence
and converts it to a
Number
. The parsePosition will be set
to the character following the last character parsed.
- Parameters:
- text - The string to parse the number from.
- parsePosition - On input, contains the position in text to start
parse at. On return, contains the position that caused parsing to stop.
- Returns:
- The parsed number. This will be an instance of java.lang.Long.
main
public static void main(String args[]) throws Exception
- This method is for testing the class.
- Parameters:
- args - The first argument should be either true or false. It
determines if the returned string is uppercase (true) or lowercase
(false). The second argument should be a number to format.
All Packages Class Hierarchy This Package Previous Next Index