|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smithers.extras.NumberString
public class NumberString
Provides a series of methods for converting between numeric values, and
String
s. Supports the following:
Type | long | double |
Digits | Supported | Output only |
Words | Output only Options: language, scale |
Output only Options: language, scale |
Roman Numerals | Output only | Unsupported |
Languages |
English |
French/Francais |
German/Deutsch |
NumberString
object contains a number (either a long
or a
double
) as well as the options to be used. Type | Prefix | Function |
Accessors | get | Get the number or option. |
Modifiers | set | Set the number or option. |
Encoders | to | Format the number in the specified style. |
Decoders | from | Parse a string in from the specified style. |
Field Summary | |
---|---|
static java.lang.String |
DEUTSCH
German |
static java.lang.String |
ENGLISH
English |
static java.lang.String |
FRANCAIS
French |
static java.lang.String |
FRENCH
French |
static java.lang.String |
GERMAN
German |
static int |
LONG_SCALE_MILLIARD
The long scale. |
static int |
LONG_SCALE_NO_MILLIARD
The long scale. |
static int |
SHORT_SCALE
The short scale. |
Constructor Summary | |
---|---|
NumberString()
Constructs a new NumberString object with the default properties. |
|
NumberString(java.lang.String language)
Constructs a new NumberString object with properties derived
from a specified language. |
|
NumberString(java.lang.String language,
int scale)
Constructs a new NumberString object with the specified
properties. |
Method Summary | |
---|---|
java.lang.String |
getLanguage()
Gets the language of this NumberString . |
int |
getScale()
Gets the scale of this NumberString . |
static long |
longFromDigits(java.lang.String text)
Converts a string of digits into a long value. |
long |
longFromWords(java.lang.String text)
Converts a string of words into a long value. |
static void |
main(java.lang.String[] args)
For testing. |
void |
setLanguage(java.lang.String language)
Sets the language of this NumberString . |
void |
setOptions(java.lang.String language)
Sets the all the options of this NumberString based on a
language. |
void |
setScale(int scale)
Sets the scale of this NumberString . |
static java.lang.String |
toDigits(double number)
Converts a double value into a string of digits. |
java.lang.String |
toDigits(long number)
Converts a long value into a string of digits. |
java.lang.String |
toRomanNumerals(long number)
Converts a long value into a string of roman numerals. |
java.lang.String |
toWords(double number)
Converts a double value into a string of words. |
java.lang.String |
toWords(long number)
Converts a long value into a string of words. |
static java.lang.String |
toWords(long number,
java.lang.String language)
Converts a long value into a string of words using the specified
language. |
static java.lang.String |
toWords(long number,
java.lang.String language,
int scale)
Converts a long value into a string of words using the specified
language and scale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ENGLISH
public static final java.lang.String FRENCH
public static final java.lang.String FRANCAIS
public static final java.lang.String GERMAN
public static final java.lang.String DEUTSCH
public static final int SHORT_SCALE
public static final int LONG_SCALE_NO_MILLIARD
public static final int LONG_SCALE_MILLIARD
Constructor Detail |
---|
public NumberString()
NumberString
object with the default properties.
public NumberString(java.lang.String language)
NumberString
object with properties derived
from a specified language. The parameter should be one of the
language constants defined in this class.
language
- the languagepublic NumberString(java.lang.String language, int scale)
NumberString
object with the specified
properties. The parameters should be chosen from the language and scale
constants defined in this class.
language
- the languagescale
- the scale to useMethod Detail |
---|
public java.lang.String getLanguage()
NumberString
.
public int getScale()
NumberString
.
public void setOptions(java.lang.String language)
NumberString
based on a
language. The parameter should be equal to one of the language constants
defined in this class.
language
- the language to derive the options frompublic void setLanguage(java.lang.String language)
NumberString
. The parameter should be
equal to one of the language constants defined in this class.
language
- the new languagepublic void setScale(int scale)
NumberString
. The parameter should be
equal to one of the scale constants defined in this class.
scale
- the new scalepublic java.lang.String toDigits(long number)
long
value into a string of digits.
number
- the long value
number
in base 10public static java.lang.String toDigits(double number)
double
value into a string of digits.
number
- the double value
number
in base 10public static long longFromDigits(java.lang.String text)
long
value.
text
- the string of digits
long
value of the string in base 10public java.lang.String toWords(long number)
long
value into a string of words.
number
- the long value
number
public static java.lang.String toWords(long number, java.lang.String language)
long
value into a string of words using the specified
language. Determines the scale based on the language.
number
- the long valuelanguage
- the language to use
number
toWords(long)
public static java.lang.String toWords(long number, java.lang.String language, int scale)
long
value into a string of words using the specified
language and scale.
number
- the long valuelanguage
- the language to usescale
- the scale to use
toWords(long)
public java.lang.String toWords(double number)
double
value into a string of words. Tentative
number
- the double value
public long longFromWords(java.lang.String text)
long
value.
IN PROGRESS. ENGLISH ONLY.
text
- a string of words
public java.lang.String toRomanNumerals(long number)
long
value into a string of roman numerals. Warning:
do not use for values >>1000 since this can take a very long time
and generate a very long string.
number
- the long value
number
public static void main(java.lang.String[] args)
NumberString
and a number and
attempts to output it using each of the three methods. Run with the
-h
option to list options.
args
- the arguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |