From 9ad9619a3cebf656e8daeca8864455f32fbf8ee3 Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 18 Oct 2024 14:21:09 +0300 Subject: [PATCH] Update RuleIdComparator --- .../verapdf/pdfa/validation/profiles/Profiles.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java index 5d2ea19cb..db8987f11 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java @@ -551,14 +551,16 @@ public int compare(RuleId firstId, RuleId secondId) { String[] o1StrArr = firstId.getClause().split("\\."); //$NON-NLS-1$ String[] o2StrArr = secondId.getClause().split("\\."); //$NON-NLS-1$ int min = Math.min(o1StrArr.length, o2StrArr.length); - - for (int i = 0; i < min; ++i) { - if (!o1StrArr[i].equals(o2StrArr[i])) { - return Integer.parseInt(o1StrArr[i]) - Integer.parseInt(o2StrArr[i]); + try { + for (int i = 0; i < min; ++i) { + if (!o1StrArr[i].equals(o2StrArr[i])) { + return Integer.parseInt(o1StrArr[i]) - Integer.parseInt(o2StrArr[i]); + } } + return o1StrArr.length - o2StrArr.length; + } catch (NumberFormatException e) { + return firstId.getClause().compareTo(secondId.getClause()); } - - return o1StrArr.length - o2StrArr.length; } }