Package org.orekit.utils.formatting
Class FastDoubleFormatter
- java.lang.Object
-
- org.orekit.utils.formatting.FastDoubleFormatter
-
- Direct Known Subclasses:
FastDecimalFormatter,FastScientificFormatter
public abstract class FastDoubleFormatter extends Object
Formatter for double numbers with low overhead.This class is intended to be used when formatting large amounts of data with fixed formats like, for example, large ephemeris or measurement files.
Building the formatter is done once, and the formatter
appendTo(Appendable, double)ortoString(double)methods can be called hundreds of thousands of times, without incurring the overhead that would occur withString.format(). Some tests showed this formatter is about 5 times faster thanString.format()with%{width}.{%precision}fformat.Instances of this class are immutable
- Since:
- 14.0
- Author:
- Luc Maisonobe
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFastDoubleFormatter(int width)Simple constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidappendRegularValueTo(Appendable appendable, double value)Append one formatted value to anAppendable.voidappendTo(Appendable appendable, double value)Append one formatted value to anAppendable.intgetWidth()Get the width.StringtoString(double value)Format one value.
-
-
-
Constructor Detail
-
FastDoubleFormatter
protected FastDoubleFormatter(int width)
Simple constructor.This constructor is equivalent to
Formatterfloat format%{width}.{precision}f- Parameters:
width- number of characters to output
-
-
Method Detail
-
getWidth
public int getWidth()
Get the width.- Returns:
- width
-
appendTo
public void appendTo(Appendable appendable, double value) throws IOException
Append one formatted value to anAppendable.- Parameters:
appendable- to append value tovalue- value to format- Throws:
IOException- if an I/O error occurs
-
appendRegularValueTo
protected abstract void appendRegularValueTo(Appendable appendable, double value) throws IOException
Append one formatted value to anAppendable.- Parameters:
appendable- to append value tovalue- value to format- Throws:
IOException- if an I/O error occurs
-
toString
public String toString(double value)
Format one value.- Parameters:
value- value to format- Returns:
- formatted string
-
-