public enum NumberSystem extends Enum<NumberSystem>
Defines the number system.
Attention: This enum can only handle non-negative integers.
| Enum Constant and Description |
|---|
ARABIC
Arabic numbers with the decimal digits 0-9 (default setting).
|
ARABIC_INDIC
Arabic-Indic numbers (used in many Arabic countries).
|
ARABIC_INDIC_EXT
Extended Arabic-Indic numbers (used for example in Iran).
|
BENGALI
The Bengali digits used in parts of India.
|
DEVANAGARI
The Devanagari digits used in parts of India.
|
DOZENAL
Dozenal numbers describe a 12-based positional numbering system.
|
ETHIOPIC
Ethiopic numerals (always positive).
|
GUJARATI
The Gujarati digits used in parts of India.
|
JAPANESE
The Japanese numbers limited to the range 1-9999.
|
KHMER
Traditional number system used by Khmer people in Cambodia.
|
MYANMAR
The number system used in Myanmar (Burma).
|
ORYA
The Orya digits used in parts of India.
|
ROMAN
Roman numerals in range 1-3999.
|
TELUGU
The Telugu digits used in parts of India.
|
THAI
The Thai digits used in Thailand (Siam).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(char digit)
Does this number system contains given digit char?
|
String |
getCode()
Obtains an identifier which can be used together with the unicode extension "nu"
in
Locale-parameters. |
String |
getDigits()
Defines all digit characters from the smallest to the largest one.
|
boolean |
isDecimal()
Does this number system describe a decimal system where the digits can be mapped to the range 0-9?
|
int |
toInteger(String numeral)
Converts given text numeral to an integer in smart mode.
|
int |
toInteger(String numeral,
Leniency leniency)
Converts given text numeral to an integer.
|
String |
toNumeral(int number)
Converts given integer to a text numeral.
|
int |
toNumeral(int number,
Appendable buffer)
Converts given integer to a text numeral which will then
be written into buffer.
|
static NumberSystem |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static NumberSystem[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final NumberSystem ARABIC
This number system is used worldwide. Direct conversion of negative integers is not supported.
Code: "latn" as inconsistently defined in CLDR (has nothing to do with Latin).
public static final NumberSystem ARABIC_INDIC
Note: Must not be negative. Code: "arab" as defined shortened in CLDR.
public static final NumberSystem ARABIC_INDIC_EXT
Note: Must not be negative. Code: "arabext".
public static final NumberSystem BENGALI
Note: Must not be negative. Code: "beng".
public static final NumberSystem DEVANAGARI
Note: Must not be negative. Code: "deva".
public static final NumberSystem DOZENAL
See also Wikipedia.
Note: Must not be negative. Code: "dozenal" (no CLDR-equivalent).
public static final NumberSystem ETHIOPIC
See also A Look at Ethiopic Numerals.
Attention: This enum is not a decimal system. Code: "ethiopic".
public static final NumberSystem GUJARATI
Note: Must not be negative. Code: "gujr".
public static final NumberSystem JAPANESE
public static final NumberSystem KHMER
Note: Must not be negative. Code: "khmr".
public static final NumberSystem MYANMAR
Note: Must not be negative. Code: "mymr".
public static final NumberSystem ORYA
Note: Must not be negative. Code: "orya".
public static final NumberSystem ROMAN
If the leniency is strict then parsing of Roman numerals will only follow modern usage.
The parsing is always case-insensitive. See also
Roman Numerals.
Code: "roman" (deviation from CLDR).
public static final NumberSystem TELUGU
Note: Must not be negative. Code: "telu".
public static final NumberSystem THAI
Note: Must not be negative. Code: "thai".
public static NumberSystem[] values()
for (NumberSystem c : NumberSystem.values()) System.out.println(c);
public static NumberSystem valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String toNumeral(int number)
Converts given integer to a text numeral.
number - number to be displayed as textIllegalArgumentException - if the conversion is not supported for given numberpublic int toNumeral(int number,
Appendable buffer)
throws IOException
Converts given integer to a text numeral which will then be written into buffer.
number - number to be displayed as textbuffer - the buffer where any formatted number goes toIllegalArgumentException - if the conversion is not supported for given numberIOException - if writing to the buffer failspublic final int toInteger(String numeral)
Converts given text numeral to an integer in smart mode.
numeral - text numeral to be evaluated as numberIllegalArgumentException - if given number has wrong formatArithmeticException - if int-range overflowspublic int toInteger(String numeral, Leniency leniency)
Converts given text numeral to an integer.
In most cases, the leniency will not be taken into account, but parsing of some odd roman numerals can be enabled in non-strict mode (for example: IIXX instead of XVIII).
numeral - text numeral to be evaluated as numberleniency - determines how lenient the parsing of given numeral should beIllegalArgumentException - if given number has wrong formatArithmeticException - if int-range overflowspublic boolean contains(char digit)
Does this number system contains given digit char?
digit - numerical char to be checkedpublic String getDigits()
Defines all digit characters from the smallest to the largest one.
Note: If letters are used as digits then the upper case will be used.
public boolean isDecimal()
Does this number system describe a decimal system where the digits can be mapped to the range 0-9?
public String getCode()
Obtains an identifier which can be used together with the unicode extension "nu"
in Locale-parameters.
Example: Locale.forLanguageTag("th-TH-u-nu-" + NumberSystem.THAI.getCode())
would set the Thai-number-system where the code "thai" is used.
Copyright © 2014–2017. All rights reserved.