Class SimpleTupleFormat
java.lang.Object
org.apache.commons.geometry.core.internal.SimpleTupleFormat
Class for performing simple formatting and parsing of real number tuples.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSimpleTupleFormat(String prefix, String suffix) Constructs a new instance with the default string separator (a comma) and the given prefix and suffix.protectedSimpleTupleFormat(String separator, String prefix, String suffix) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionformat(double a) Return a tuple string with the given value.format(double a1, double a2) Return a tuple string with the given values.format(double a1, double a2, double a3) Return a tuple string with the given values.format(double a1, double a2, double a3, double a4) Return a tuple string with the given values.static SimpleTupleFormatReturn an instance configured with default values.Return the string used to signal the start of a tuple.Return the string used to separate tuple values.Returns the string used to signal the end of a tuple.<T> Tparse(String str, DoubleFunction1N<T> fn) Parse the given string as a 1-tuple and passes the tuple values to the given function.<T> Tparse(String str, DoubleFunction2N<T> fn) Parse the given string as a 2-tuple and passes the tuple values to the given function.<T> Tparse(String str, DoubleFunction3N<T> fn) Parse the given string as a 3-tuple and passes the parsed values to the given function.
-
Constructor Details
-
SimpleTupleFormat
Constructs a new instance with the default string separator (a comma) and the given prefix and suffix.- Parameters:
prefix- String used to signal the start of a tuple; if null, no string is expected at the start of the tuplesuffix- String used to signal the end of a tuple; if null, no string is expected at the end of the tuple
-
SimpleTupleFormat
Simple constructor.- Parameters:
separator- String used to separate tuple values; must not be null.prefix- String used to signal the start of a tuple; if null, no string is expected at the start of the tuplesuffix- String used to signal the end of a tuple; if null, no string is expected at the end of the tuple
-
-
Method Details
-
getSeparator
Return the string used to separate tuple values.- Returns:
- the value separator string
-
getPrefix
-
getSuffix
-
format
-
format
-
format
-
format
-
parse
Parse the given string as a 1-tuple and passes the tuple values to the given function. The function output is returned.- Type Parameters:
T- function return type- Parameters:
str- the string to be parsedfn- function that will be passed the parsed tuple values- Returns:
- object returned by
fn - Throws:
IllegalArgumentException- if the input string format is invalid
-
parse
Parse the given string as a 2-tuple and passes the tuple values to the given function. The function output is returned.- Type Parameters:
T- function return type- Parameters:
str- the string to be parsedfn- function that will be passed the parsed tuple values- Returns:
- object returned by
fn - Throws:
IllegalArgumentException- if the input string format is invalid
-
parse
Parse the given string as a 3-tuple and passes the parsed values to the given function. The function output is returned.- Type Parameters:
T- function return type- Parameters:
str- the string to be parsedfn- function that will be passed the parsed tuple values- Returns:
- object returned by
fn - Throws:
IllegalArgumentException- if the input string format is invalid
-
getDefault
Return an instance configured with default values. Tuples in this format are enclosed by parentheses and separated by commas. Ex:"(1.0)" "(1.0, 2.0)" "(1.0, 2.0, 3.0)"
- Returns:
- instance configured with default values
-