java.lang.Object
de.lmu.ifi.dbs.elki.utilities.FormatUtil
Utility methods for output formatting of various number objects
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The system newline setting.static final NumberFormat
Dynamic number formatter, but with language constraint.static final NumberFormat
Number Formatter (0 digits) for output purposes.static final NumberFormat
Number Formatter (2 digits) for output purposes.static final NumberFormat
Number Formatter (4 digits) for output purposes.static final NumberFormat
Number Formatter (6 digits) for output purposes.static final NumberFormat
Number Formatter (8 digits) for output purposes.static final String
Non-breaking unicode space character. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
findSplitpoint
(String s, int width) Find the first space before position w or if there is none after w.static String
format
(boolean b) Formats the boolean b.static String
Formats the boolean array b with ',' as separator.static String
format
(byte[] a) Formats the byte array a for printing purposes.static String
format
(double d) Formats the double d with 2 fraction digits.static String
format
(double[] d) Formats the double array d with ',' as separator and 2 fraction digits.static String
format
(double[][] d) Formats the double array d with ',' as separator and 2 fraction digits.static String
Formats the array of double arrays d with 'the specified separators and fraction digits.static String
format
(double[] d, int digits) Formats the double array d with ', ' as separator and with the specified fraction digits.static String
Formats the double array d with the specified separator.static String
Formats the double array d with the specified separator and the specified fraction digits.static String
format
(double[] d, String sep, NumberFormat nf) Formats the double array d with the specified number format.static String
format
(double[] d, NumberFormat nf) Formats the double array d with the specified number format.static String
format
(double d, int digits) Formats the double d with the specified fraction digits.static String
format
(double d, NumberFormat nf) Formats the double d with the specified number format.static String
format
(float[] f) Formats the float array f with ',' as separator and 2 fraction digits.static String
Formats the float array f with the specified separator and the specified fraction digits.static String
format
(int[] a) Formats the int array a for printing purposes.static String
Formats the int array a for printing purposes.static String
Returns a string representation of the specified bit set.static String
format
(long[] a) Formats the long array a for printing purposes.static String
returns String-representation of Matrix.static String
Returns a string representation of this matrix.static String
Returns a string representation of this matrix.static String
format
(Matrix m, String pre, NumberFormat nf) Returns a string representation of this matrix.static String
format
(Matrix m, NumberFormat nf) returns String-representation of Matrix.static String
Returns String-representation of Vector.static String
Returns a string representation of this matrix.static String
Returns a string representation of this matrix.static String
format
(Vector m, NumberFormat nf) returns String-representation of Vector.static String
Formats the Double array f with ',' as separator and 2 fraction digits.static String
Formats the Double array f with the specified separator and the specified fraction digits.static String
format
(Double[] f, String sep, NumberFormat nf) Formats the Double array f with the specified separator and the specified fraction digits.static String
format
(Double[] f, NumberFormat nf) Formats the Double array f with ',' as separator and 2 fraction digits.static String
Formats the Integer array a for printing purposes.static String
Formats the Integer array a for printing purposes.static String
Formats the string array d with the specified separator.static String
Returns a string representation of the specified bit set.static String
format
(Collection<String> d, String sep) Formats the String collection with the specified separator.static String
formatTimeDelta
(long time, CharSequence sep) Formats a time delta in human readable format.static int
Get the width of the terminal window (on Unix xterms), with a default of 78 characters.static String
Pad a string to a given length by adding whitespace to the right.static String
padRightAligned
(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 String
whitespace
(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 Stringpre
is 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 Stringpre
is 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 Stringpre<\code> is prefixed.
- Parameters:
nf
- number format for output accuracypre
- the prefix of each line- 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
-1
if 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
-