Skip to content

Commit

Permalink
Adapt to pt -> dot change in QUDT IRIs
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleedorfer committed Mar 4, 2024
1 parent 8203f85 commit a04effd
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit a04effd

Please sign in to comment.