Class DataUtils
java.lang.Object
de.erichseifert.vectorgraphics2d.util.DataUtils
Abstract class that contains utility functions for working with data
collections like maps or lists.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final DecimalFormatStandard pattern to format numbersprivate static final DecimalFormat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList(double[] elements) Converts an array ofdoublenumbers to a list ofDoubles.asList(float[] elements) Converts an array offloatnumbers to a list ofFloats.static StringReturns a formatted string of the specified number.static StringReturns a formatted string of the specified object.static StringReturns a string containing all double numbers concatenated by a specified separator.static StringReturns a string containing all float numbers concatenated by a specified separator.static StringReturns a string containing all elements concatenated by a specified separator.static StringReturns a string containing all elements concatenated by a specified separator.static <K,V> Map <K, V> map(K[] keys, V[] values) Creates a mapping from two arrays, one with keys, one with values.static intmax(int... values) Returns the largest of all specified values.static StringstripTrailing(String s, String substr) Removes the specified trailing pattern from a string.static voidtransfer(InputStream in, OutputStream out, int bufferSize) Copies data from an input stream to an output stream using a buffer of specified size.
-
Field Details
-
DOUBLE_FORMAT
Standard pattern to format numbers -
FLOAT_FORMAT
-
-
Constructor Details
-
DataUtils
DataUtils()Default constructor that prevents creation of class.
-
-
Method Details
-
map
Creates a mapping from two arrays, one with keys, one with values.- Type Parameters:
K- Data type of the keys.V- Data type of the values.- Parameters:
keys- Array containing the keys.values- Array containing the values.- Returns:
- Map with keys and values from the specified arrays.
-
join
Returns a string containing all elements concatenated by a specified separator.- Parameters:
separator- Separator string.elements- List of elements that should be concatenated.- Returns:
- a concatenated string.
-
join
Returns a string containing all elements concatenated by a specified separator.- Parameters:
separator- Separator string.elements- Array of elements that should be concatenated.- Returns:
- a concatenated string.
-
join
Returns a string containing all double numbers concatenated by a specified separator.- Parameters:
separator- Separator string.elements- Array of double numbers that should be concatenated.- Returns:
- a concatenated string.
-
join
Returns a string containing all float numbers concatenated by a specified separator.- Parameters:
separator- Separator string.elements- Array of float numbers that should be concatenated.- Returns:
- a concatenated string.
-
max
public static int max(int... values) Returns the largest of all specified values.- Parameters:
values- Several integer values.- Returns:
- largest value.
-
transfer
Copies data from an input stream to an output stream using a buffer of specified size.- Parameters:
in- Input stream.out- Output stream.bufferSize- Size of the copy buffer.- Throws:
IOException- when an error occurs while copying.
-
format
Returns a formatted string of the specified number. All trailing zeroes or decimal points will be stripped.- Parameters:
number- Number to convert to a string.- Returns:
- A formatted string.
-
format
Returns a formatted string of the specified object.- Parameters:
obj- Object to convert to a string.- Returns:
- A formatted string.
-
asList
Converts an array offloatnumbers to a list ofFloats. The list will be empty if the array is empty ornull.- Parameters:
elements- Array of float numbers.- Returns:
- A list with all numbers as
Float.
-
asList
Converts an array ofdoublenumbers to a list ofDoubles. The list will be empty if the array is empty ornull.- Parameters:
elements- Array of double numbers.- Returns:
- A list with all numbers as
Double.
-
stripTrailing
Removes the specified trailing pattern from a string.- Parameters:
s- string.substr- trailing pattern.- Returns:
- A string without the trailing pattern.
-