Package org.orekit.utils.formatting
Class FastLongFormatter
java.lang.Object
org.orekit.utils.formatting.FastLongFormatter
Formatter for long integers 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, long) or toString(long) methods can be
called hundreds of thousands of times, without incurring the overhead that
would occur with String.format(). Some tests showed this formatter is
about 10 times faster than String.format() with %{width}d format.
Instances of this class are immutable
- Since:
- 13.0.3
- Author:
- Luc Maisonobe
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTo(Appendable appendable, long value) Append one formatted value to anAppendable.intgetWidth()Get the width.booleanCheck if left padding uses '0' characters.toString(long value) Format one value.
-
Constructor Details
-
FastLongFormatter
public FastLongFormatter(int width, boolean zeroPadding) Simple constructor.This constructor is equivalent to either
Formatterinteger format%{width}dor%0{width}d- Parameters:
width- number of characters to outputzeroPadding- if true, the result is left padded with '0' until it matches width
-
-
Method Details
-
getWidth
public int getWidth()Get the width.- Returns:
- width
-
hasZeroPadding
public boolean hasZeroPadding()Check if left padding uses '0' characters.- Returns:
- true if left padding uses '0' characters
-
appendTo
Append one formatted value to anAppendable.- Parameters:
appendable- to append value tovalue- value to format- Throws:
IOException- if an I/O error occurs
-
toString
Format one value.- Parameters:
value- value to format- Returns:
- formatted string
-