Package me.datafox.dfxengine.text.suffix
Class CharDigitSuffixFormatter
java.lang.Object
me.datafox.dfxengine.text.suffix.CharDigitSuffixFormatter
- All Implemented Interfaces:
Comparable<Handled>,Handled,NumberSuffixFormatter
A
NumberSuffixFormatter that generates an exponential suffix in an arbitrary base with an arbitrary set of
characters representing digits. The character set can be configured with CHARACTERS, and INTERVAL
determines how many powers of ten is required for the exponent to increase. The formatter can also be configured to
output a plus sign on positive exponents with EXPONENT_PLUS.-
Nested Class Summary
Nested classes/interfaces inherited from interface me.datafox.dfxengine.text.api.NumberSuffixFormatter
NumberSuffixFormatter.Output -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]26 English alphabet in lowercase.static final ConfigurationKey<char[]> Characters to be used as digits for the exponent.static final ConfigurationKey<Boolean> Iftrue, will output a plus sign on positive exponents.static final ConfigurationKey<Integer> Interval for formatted exponents. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat(BigDecimal number, TextFactory factory, TextConfiguration configuration) boolean
-
Field Details
-
ALPHABET
public static final char[] ALPHABET26 English alphabet in lowercase. -
CHARACTERS
Characters to be used as digits for the exponent. The default value isALPHABET. -
INTERVAL
Interval for formatted exponents. The default value is3. -
EXPONENT_PLUS
Iftrue, will output a plus sign on positive exponents. The default value isfalse.
-
-
Constructor Details
-
CharDigitSuffixFormatter
- Parameters:
logger-Loggerfor this formatterhandles-TextHandlesto be used for this formatter'sHandle
-
-
Method Details
-
format
public NumberSuffixFormatter.Output format(BigDecimal number, TextFactory factory, TextConfiguration configuration) - Specified by:
formatin interfaceNumberSuffixFormatter- Parameters:
number- number to formatfactory-TextFactoryfor formattingconfiguration-TextConfigurationfor formatting- Returns:
NumberSuffixFormatter.Outputcontaining the scaled number and a suffix, or theNumberSuffixFormatter.OutputofTextFactory.getDefaultNumberSuffixFormatter()if the number cannot be formatted by this formatter- Throws:
TextConfigurationException- if theTextConfigurationis not valid for this formatter
-
isInfinite
public boolean isInfinite()- Specified by:
isInfinitein interfaceNumberSuffixFormatter- Returns:
trueif this formatter can format anyBigDecimalnumber. Always returnstrue
-