diff --git a/qudtlib-model/src/main/java/io/github/qudtlib/model/DimensionVector.java b/qudtlib-model/src/main/java/io/github/qudtlib/model/DimensionVector.java index 7dcd322..2721dab 100644 --- a/qudtlib-model/src/main/java/io/github/qudtlib/model/DimensionVector.java +++ b/qudtlib-model/src/main/java/io/github/qudtlib/model/DimensionVector.java @@ -6,6 +6,7 @@ import java.util.Objects; import java.util.Optional; import java.util.logging.Logger; +import java.util.regex.Pattern; /** * Represents the QUDT dimension vector and allows for converting between a dimension vector IRI and @@ -34,7 +35,9 @@ public class DimensionVector { FORMAT = new DecimalFormat("0.#", symbols); } - private static String PT = "pt"; + private static String DOT = "dot"; + + private static Pattern DECIMAL_POINT_PATTERN = Pattern.compile("(pt|dot)"); public static DimensionVector DIMENSIONLESS = new DimensionVector(new int[] {0, 0, 0, 0, 0, 0, 0, 1}); @@ -91,8 +94,10 @@ public DimensionVector(String dimensionVectorIri) { } dimValues[i] = Float.parseFloat( - numbers[i + 1].replace( - "pt", ".")); // split produces an empty first array element + DECIMAL_POINT_PATTERN + .matcher(numbers[i + 1]) + .replaceAll(".")); // split produces an empty first array + // element } } @@ -147,7 +152,7 @@ private static String iriFormat(float dimensionValues) { return "0"; } - return FORMAT.format(dimensionValues).replace(".", "pt"); + return FORMAT.format(dimensionValues).replace(".", DOT); } public DimensionVector() {