Class DoubleFormat.AbstractDoubleFormat

java.lang.Object
org.apache.commons.text.numbers.DoubleFormat.AbstractDoubleFormat
All Implemented Interfaces:
DoubleFunction<String>, ParsedDecimal.FormatOptions
Direct Known Subclasses:
DoubleFormat.EngineeringDoubleFormat, DoubleFormat.MixedDoubleFormat, DoubleFormat.PlainDoubleFormat, DoubleFormat.ScientificDoubleFormat
Enclosing class:
DoubleFormat

private abstract static class DoubleFormat.AbstractDoubleFormat extends Object implements DoubleFunction<String>, ParsedDecimal.FormatOptions
Base class for standard double formatting classes.
  • Field Details

    • maxPrecision

      private final int maxPrecision
      Maximum precision; 0 indicates no limit.
    • minDecimalExponent

      private final int minDecimalExponent
      Minimum decimal exponent.
    • positiveInfinity

      private final String positiveInfinity
      String representing positive infinity.
    • negativeInfinity

      private final String negativeInfinity
      String representing negative infinity.
    • nan

      private final String nan
      String representing NaN.
    • fractionPlaceholder

      private final boolean fractionPlaceholder
      Flag determining if fraction placeholders should be used.
    • signedZero

      private final boolean signedZero
      Flag determining if signed zero strings are allowed.
    • digits

      private final char[] digits
      String containing the digits 0-9.
    • decimalSeparator

      private final char decimalSeparator
      Decimal separator character.
    • groupingSeparator

      private final char groupingSeparator
      Thousands grouping separator.
    • groupThousands

      private final boolean groupThousands
      Flag indicating if thousands should be grouped.
    • minusSign

      private final char minusSign
      Minus sign character.
    • exponentSeparatorChars

      private final char[] exponentSeparatorChars
      Exponent separator character.
    • alwaysIncludeExponent

      private final boolean alwaysIncludeExponent
      Flag indicating if exponent values should always be included, even if zero.
  • Constructor Details

    • AbstractDoubleFormat

      AbstractDoubleFormat(DoubleFormat.Builder builder)
      Constructs a new instance.
      Parameters:
      builder - builder instance containing configuration values
  • Method Details

    • apply

      public String apply(double d)
      Specified by:
      apply in interface DoubleFunction<String>
    • applyFinite

      private String applyFinite(double d)
      Returns a formatted string representation of the given finite value.
      Parameters:
      d - double value
    • applyFiniteInternal

      protected abstract String applyFiniteInternal(ParsedDecimal val)
      Returns a formatted representation of the given rounded decimal value to dst.
      Parameters:
      val - value to format
      Returns:
      a formatted representation of the given rounded decimal value to dst.
    • getDecimalSeparator

      public char getDecimalSeparator()
      Get the decimal separator character.
      Specified by:
      getDecimalSeparator in interface ParsedDecimal.FormatOptions
      Returns:
      decimal separator character
    • getDigits

      public char[] getDigits()
      Get an array containing the localized digit characters 0-9 in that order. This string must be non-null and have a length of 10.
      Specified by:
      getDigits in interface ParsedDecimal.FormatOptions
      Returns:
      array containing the digit characters 0-9
    • getExponentSeparatorChars

      public char[] getExponentSeparatorChars()
      Get the exponent separator as an array of characters.
      Specified by:
      getExponentSeparatorChars in interface ParsedDecimal.FormatOptions
      Returns:
      exponent separator as an array of characters
    • getGroupingSeparator

      public char getGroupingSeparator()
      Get the character used to separate thousands groupings.
      Specified by:
      getGroupingSeparator in interface ParsedDecimal.FormatOptions
      Returns:
      character used to separate thousands groupings
    • getMinusSign

      public char getMinusSign()
      Get the minus sign character.
      Specified by:
      getMinusSign in interface ParsedDecimal.FormatOptions
      Returns:
      minus sign character
    • isAlwaysIncludeExponent

      public boolean isAlwaysIncludeExponent()
      Return true if exponent values should always be included in formatted output, even if the value is zero.
      Specified by:
      isAlwaysIncludeExponent in interface ParsedDecimal.FormatOptions
      Returns:
      true if exponent values should always be included
    • isGroupThousands

      public boolean isGroupThousands()
      Return true if thousands should be grouped.
      Specified by:
      isGroupThousands in interface ParsedDecimal.FormatOptions
      Returns:
      true if thousand should be grouped
    • isIncludeFractionPlaceholder

      public boolean isIncludeFractionPlaceholder()
      Return true if fraction placeholders (e.g., ".0" in "1.0") should be included.
      Specified by:
      isIncludeFractionPlaceholder in interface ParsedDecimal.FormatOptions
      Returns:
      true if fraction placeholders should be included
    • isSignedZero

      public boolean isSignedZero()
      Return true if the string zero should be prefixed with the minus sign for negative zero values.
      Specified by:
      isSignedZero in interface ParsedDecimal.FormatOptions
      Returns:
      true if the minus zero string should be allowed