java.lang.Object
de.lmu.ifi.dbs.elki.utilities.FormatUtil
Utility methods for output formatting of various number objects
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe system newline setting.static final NumberFormatDynamic number formatter, but with language constraint.static final NumberFormatNumber Formatter (0 digits) for output purposes.static final NumberFormatNumber Formatter (2 digits) for output purposes.static final NumberFormatNumber Formatter (4 digits) for output purposes.static final NumberFormatNumber Formatter (6 digits) for output purposes.static final NumberFormatNumber Formatter (8 digits) for output purposes.static final StringNon-breaking unicode space character. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindSplitpoint(String s, int width) Find the first space before position w or if there is none after w.static Stringformat(boolean b) Formats the boolean b.static StringFormats the boolean array b with ',' as separator.static Stringformat(byte[] a) Formats the byte array a for printing purposes.static Stringformat(double d) Formats the double d with 2 fraction digits.static Stringformat(double[] d) Formats the double array d with ',' as separator and 2 fraction digits.static Stringformat(double[][] d) Formats the double array d with ',' as separator and 2 fraction digits.static StringFormats the array of double arrays d with 'the specified separators and fraction digits.static Stringformat(double[] d, int digits) Formats the double array d with ', ' as separator and with the specified fraction digits.static StringFormats the double array d with the specified separator.static StringFormats the double array d with the specified separator and the specified fraction digits.static Stringformat(double[] d, String sep, NumberFormat nf) Formats the double array d with the specified number format.static Stringformat(double[] d, NumberFormat nf) Formats the double array d with the specified number format.static Stringformat(double d, int digits) Formats the double d with the specified fraction digits.static Stringformat(double d, NumberFormat nf) Formats the double d with the specified number format.static Stringformat(float[] f) Formats the float array f with ',' as separator and 2 fraction digits.static StringFormats the float array f with the specified separator and the specified fraction digits.static Stringformat(int[] a) Formats the int array a for printing purposes.static StringFormats the int array a for printing purposes.static StringReturns a string representation of the specified bit set.static Stringformat(long[] a) Formats the long array a for printing purposes.static Stringreturns String-representation of Matrix.static StringReturns a string representation of this matrix.static StringReturns a string representation of this matrix.static Stringformat(Matrix m, String pre, NumberFormat nf) Returns a string representation of this matrix.static Stringformat(Matrix m, NumberFormat nf) returns String-representation of Matrix.static StringReturns String-representation of Vector.static StringReturns a string representation of this matrix.static StringReturns a string representation of this matrix.static Stringformat(Vector m, NumberFormat nf) returns String-representation of Vector.static StringFormats the Double array f with ',' as separator and 2 fraction digits.static StringFormats the Double array f with the specified separator and the specified fraction digits.static Stringformat(Double[] f, String sep, NumberFormat nf) Formats the Double array f with the specified separator and the specified fraction digits.static Stringformat(Double[] f, NumberFormat nf) Formats the Double array f with ',' as separator and 2 fraction digits.static StringFormats the Integer array a for printing purposes.static StringFormats the Integer array a for printing purposes.static StringFormats the string array d with the specified separator.static StringReturns a string representation of the specified bit set.static Stringformat(Collection<String> d, String sep) Formats the String collection with the specified separator.static StringformatTimeDelta(long time, CharSequence sep) Formats a time delta in human readable format.static intGet the width of the terminal window (on Unix xterms), with a default of 78 characters.static StringPad a string to a given length by adding whitespace to the right.static StringpadRightAligned(String o, int len) Pad a string to a given length by adding whitespace to the left.splitAtLastBlank(String s, int width) Splits the specified string at the last blank before width.static Stringwhitespace(int n) Returns a string with the specified number of whitespace.
-
Field Details
-
NF
Dynamic number formatter, but with language constraint. -
NF0
Number Formatter (0 digits) for output purposes. -
NF2
Number Formatter (2 digits) for output purposes. -
NF4
Number Formatter (4 digits) for output purposes. -
NF6
Number Formatter (6 digits) for output purposes. -
NF8
Number Formatter (8 digits) for output purposes. -
NEWLINE
The system newline setting. -
NONBREAKING_SPACE
Non-breaking unicode space character.- See Also:
-
-
Constructor Details
-
FormatUtil
public FormatUtil()
-
-
Method Details
-
format
Formats the double d with the specified fraction digits.- Parameters:
d- the double array to be formatteddigits- the number of fraction digits- Returns:
- a String representing the double d
-
format
Formats the double d with the specified number format.- Parameters:
d- the double array to be formattednf- the number format to be used for formatting- Returns:
- a String representing the double d
-
format
Formats the double d with 2 fraction digits.- Parameters:
d- the double to be formatted- Returns:
- a String representing the double d
-
format
Formats the double array d with the specified separator.- Parameters:
d- the double array to be formattedsep- the separator between the single values of the double array, e.g. ','- Returns:
- a String representing the double array d
-
format
Formats the double array d with the specified separator and the specified fraction digits.- Parameters:
d- the double array to be formattedsep- the separator between the single values of the double array, e.g. ','digits- the number of fraction digits- Returns:
- a String representing the double array d
-
format
Formats the double array d with the specified number format.- Parameters:
d- the double array to be formattednf- the number format to be used for formatting- Returns:
- a String representing the double array d
-
format
Formats the double array d with the specified number format.- Parameters:
d- the double array to be formattedsep- the separator between the single values of the double array, e.g. ','nf- the number format to be used for formatting- Returns:
- a String representing the double array d
-
format
Formats the double array d with ',' as separator and 2 fraction digits.- Parameters:
d- the double array to be formatted- Returns:
- a String representing the double array d
-
format
Formats the double array d with ', ' as separator and with the specified fraction digits.- Parameters:
d- the double array to be formatteddigits- the number of fraction digits- Returns:
- a String representing the double array d
-
format
Formats the double array d with ',' as separator and 2 fraction digits.- Parameters:
d- the double array to be formatted- Returns:
- a String representing the double array d
-
format
Formats the array of double arrays d with 'the specified separators and fraction digits.- Parameters:
d- the double array to be formattedsep1- the first separator of the outer arraysep2- the second separator of the inner arraydigits- the number of fraction digits- Returns:
- a String representing the double array d
-
format
Formats the Double array f with the specified separator and the specified fraction digits.- Parameters:
f- the Double array to be formattedsep- the separator between the single values of the Double array, e.g. ','digits- the number of fraction digits- Returns:
- a String representing the Double array f
-
format
Formats the Double array f with ',' as separator and 2 fraction digits.- Parameters:
f- the Double array to be formatted- Returns:
- a String representing the Double array f
-
format
Formats the Double array f with the specified separator and the specified fraction digits.- Parameters:
f- the Double array to be formattedsep- the separator between the single values of the Double array, e.g. ','nf- the number format- Returns:
- a String representing the Double array f
-
format
Formats the Double array f with ',' as separator and 2 fraction digits.- Parameters:
f- the Double array to be formattednf- the Number format- Returns:
- a String representing the Double array f
-
format
Formats the float array f with the specified separator and the specified fraction digits.- Parameters:
f- the float array to be formattedsep- the separator between the single values of the float array, e.g. ','digits- the number of fraction digits- Returns:
- a String representing the float array f
-
format
Formats the float array f with ',' as separator and 2 fraction digits.- Parameters:
f- the float array to be formatted- Returns:
- a String representing the float array f
-
format
Formats the int array a for printing purposes.- Parameters:
a- the int array to be formattedsep- the separator between the single values of the float array, e.g. ','- Returns:
- a String representing the int array a
-
format
Formats the int array a for printing purposes.- Parameters:
a- the int array to be formatted- Returns:
- a String representing the int array a
-
format
Formats the Integer array a for printing purposes.- Parameters:
a- the Integer array to be formattedsep- the separator between the single values of the float array, e.g. ','- Returns:
- a String representing the Integer array a
-
format
Formats the Integer array a for printing purposes.- Parameters:
a- the Integer array to be formatted- Returns:
- a String representing the Integer array a
-
format
Formats the long array a for printing purposes.- Parameters:
a- the long array to be formatted- Returns:
- a String representing the long array a
-
format
Formats the byte array a for printing purposes.- Parameters:
a- the byte array to be formatted- Returns:
- a String representing the byte array a
-
format
Formats the boolean array b with ',' as separator.- Parameters:
b- the boolean array to be formattedsep- the separator between the single values of the double array, e.g. ','- Returns:
- a String representing the boolean array b
-
format
Formats the boolean b.- Parameters:
b- the boolean to be formatted- Returns:
- a String representing of the boolean b
-
format
Returns a string representation of the specified bit set.- Parameters:
bitSet- the bitSetdim- the overall dimensionality of the bit setsep- the separator- Returns:
- a string representation of the specified bit set.
-
format
Returns a string representation of the specified bit set.- Parameters:
dim- the overall dimensionality of the bit setbitSet- the bitSet- Returns:
- a string representation of the specified bit set.
-
format
Formats the String collection with the specified separator.- Parameters:
d- the String collection to formatsep- the separator between the single values of the double array, e.g. ' '- Returns:
- a String representing the String Collection d
-
format
Returns a string representation of this matrix.- Parameters:
w- column widthd- number of digits after the decimal- Returns:
- a string representation of this matrix
-
format
Returns a string representation of this matrix.- Parameters:
w- column widthd- number of digits after the decimal- Returns:
- a string representation of this matrix
-
format
Returns a string representation of this matrix. In each line the specified Stringpreis prefixed.- Parameters:
pre- the prefix of each line- Returns:
- a string representation of this matrix
-
format
returns String-representation of Matrix.- Parameters:
nf- NumberFormat to specify output precision- Returns:
- String representation of this Matrix in precision as specified by given NumberFormat
-
format
returns String-representation of Matrix.- Returns:
- String representation of this Matrix
-
format
returns String-representation of Vector.- Parameters:
nf- NumberFormat to specify output precision- Returns:
- String representation of this Matrix in precision as specified by given NumberFormat
-
format
Returns String-representation of Vector.- Returns:
- String representation of this Vector
-
format
Returns a string representation of this matrix. In each line the specified Stringpreis prefixed.- Parameters:
pre- the prefix of each line- Returns:
- a string representation of this matrix
-
format
Returns a string representation of this matrix. In each line the specified Stringpreinvalid input: '<'\code> is prefixed.- Parameters:
pre- the prefix of each linenf- number format for output accuracy- Returns:
- a string representation of this matrix
-
findSplitpoint
Find the first space before position w or if there is none after w.- Parameters:
s- Stringwidth- Width- Returns:
- index of best whitespace or
-1if no whitespace was found.
-
splitAtLastBlank
Splits the specified string at the last blank before width. If there is no blank before the given width, it is split at the next.- Parameters:
s- the string to be splitwidth- int- Returns:
- string fragments
-
whitespace
Returns a string with the specified number of whitespace.- Parameters:
n- the number of whitespace characters- Returns:
- a string with the specified number of blanks
-
pad
Pad a string to a given length by adding whitespace to the right.- Parameters:
o- original stringlen- destination length- Returns:
- padded string of at least length len (and o otherwise)
-
padRightAligned
Pad a string to a given length by adding whitespace to the left.- Parameters:
o- original stringlen- destination length- Returns:
- padded string of at least length len (and o otherwise)
-
getConsoleWidth
public static int getConsoleWidth()Get the width of the terminal window (on Unix xterms), with a default of 78 characters.- Returns:
- Terminal width
-
formatTimeDelta
Formats a time delta in human readable format.- Parameters:
time- time delta in ms- Returns:
- Formatted string
-
format
Formats the string array d with the specified separator.- Parameters:
d- the string array to be formattedsep- the separator between the single values of the double array, e.g. ','- Returns:
- a String representing the string array d
-