public class FloatFormatter extends InternalFormat.Formatter
Constructor and Description |
---|
FloatFormatter(InternalFormat.Spec spec)
Construct the formatter from a specification, allocating a buffer internally for the result.
|
FloatFormatter(java.lang.StringBuilder result,
InternalFormat.Spec spec)
Construct the formatter from a client-supplied buffer, to which the result will be appended,
and a specification.
|
Modifier and Type | Method and Description |
---|---|
FloatFormatter |
append(char c) |
FloatFormatter |
append(java.lang.CharSequence csq) |
FloatFormatter |
append(java.lang.CharSequence csq,
int start,
int end) |
FloatFormatter |
format(double value)
Format a floating-point number according to the specification represented by this
FloatFormatter . |
FloatFormatter |
format(double value,
java.lang.String positivePrefix)
Format a floating-point number according to the specification represented by this
FloatFormatter . |
void |
setMinFracDigits(int minFracDigits)
Override the default truncation behaviour for the specification originally supplied.
|
static int |
size(InternalFormat.Spec spec)
Recommend a buffer size for a given specification, assuming one float is converted.
|
alignmentNotAllowed, alternateFormNotAllowed, alternateFormNotAllowed, getPyResult, getResult, isBytes, notAllowed, notAllowed, pad, precisionNotAllowed, precisionTooLarge, setBytes, setStart, signNotAllowed, toString, unknownFormat, zeroPaddingNotAllowed
public FloatFormatter(java.lang.StringBuilder result, InternalFormat.Spec spec)
InternalFormat.Formatter.mark
to the end of the buffer.result
- destination bufferspec
- parsed conversion specificationpublic FloatFormatter(InternalFormat.Spec spec)
spec
- parsed conversion specificationpublic static int size(InternalFormat.Spec spec)
spec
- parsed conversion specificationpublic void setMinFracDigits(int minFracDigits)
minFracDigits
, to modify this behaviour.minFracDigits
- if <0 prevent truncation; if ≥0 the minimum number of fractional
digits; when this is zero, and all fractional digits are zero, the decimal point
will also be removed.public FloatFormatter append(char c)
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
public FloatFormatter append(java.lang.CharSequence csq)
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
public FloatFormatter append(java.lang.CharSequence csq, int start, int end) throws java.lang.IndexOutOfBoundsException
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
java.lang.IndexOutOfBoundsException
public FloatFormatter format(double value)
FloatFormatter
.value
- to convertpublic FloatFormatter format(double value, java.lang.String positivePrefix)
FloatFormatter
. The conversion type, precision, and flags for grouping or
percentage are dealt with here. At the point this is used, we know the InternalFormat.Formatter.spec
is one
of the floating-point types. This entry point allows explicit control of the prefix of
positive numbers, overriding defaults for the format type.value
- to convertpositivePrefix
- to use before positive values (e.g. "+") or null to default to ""