Package me.datafox.dfxengine.text.suffix
Class ExponentSuffixFormatter
java.lang.Object
me.datafox.dfxengine.text.suffix.ExponentSuffixFormatter
- All Implemented Interfaces:
Comparable<Handled>,Handled,NumberSuffixFormatter
A
NumberSuffixFormatter that generates a traditional exponential notation suffix. Supports formatting in
scientific or engineering notation, or have any other interval that the exponents snaps to multiples of, configured
with INTERVAL. The returned format has a lowercase e, and can be configured to output a plus 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 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
-
INTERVAL
Interval for formatted exponents.1is equivalent to scientific notation and3is equivalent to engineering notation. The default value is1. -
EXPONENT_PLUS
Iftrue, will output a plus sign on positive exponents. The default value isfalse.
-
-
Constructor Details
-
ExponentSuffixFormatter
- 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
-