diff --git a/src/main/java/org/openepics/names/util/NamingConventionUtil.java b/src/main/java/org/openepics/names/util/NamingConventionUtil.java index 51e5abfe07777c1347bdffc3cd6cf9e52e88f564..68603fa7c92ed4ac60a6d4722d54b39865cf09bb 100644 --- a/src/main/java/org/openepics/names/util/NamingConventionUtil.java +++ b/src/main/java/org/openepics/names/util/NamingConventionUtil.java @@ -19,7 +19,6 @@ package org.openepics.names.util; import java.util.Arrays; -import java.util.StringTokenizer; import org.apache.commons.lang3.StringUtils; import org.openepics.names.repository.model.Discipline; @@ -138,11 +137,11 @@ public class NamingConventionUtil { // system structure // before first occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3) { - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 1 || s1.length == 2 || s1.length == 3) { + String[] s2 = s1[0].split(DELIMITER_INTRA); + if (s2.length == 3) { + return s2[0]; } } } @@ -161,14 +160,13 @@ public class NamingConventionUtil { // system structure // before first occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3) { - st2.nextToken(); - return st2.nextToken(); - } else if (st2.countTokens() == 2 || st2.countTokens() == 1) { - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 1 || s1.length == 2 || s1.length == 3) { + String[] s2 = s1[0].split(DELIMITER_INTRA); + if (s2.length == 3) { + return s2[1]; + } else if (s2.length == 2 || s2.length == 1) { + return s2[0]; } } } @@ -187,16 +185,13 @@ public class NamingConventionUtil { // system structure // before first occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3) { - st2.nextToken(); - st2.nextToken(); - return st2.nextToken(); - } else if (st2.countTokens() == 2) { - st2.nextToken(); - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 1 || s1.length == 2 || s1.length == 3) { + String[] s2 = s1[0].split(DELIMITER_INTRA); + if (s2.length == 3) { + return s2[2]; + } else if (s2.length == 2) { + return s2[1]; } } } @@ -216,12 +211,11 @@ public class NamingConventionUtil { // after first occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 2 || st1.countTokens() == 3) { - st1.nextToken(); - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3 || st2.countTokens() == 2) { - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 2 || s1.length == 3) { + String[] s2 = s1[1].split(DELIMITER_INTRA); + if (s2.length == 3 || s2.length == 2) { + return s2[0]; } } } @@ -241,13 +235,11 @@ public class NamingConventionUtil { // after first occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 2 || st1.countTokens() == 3) { - st1.nextToken(); - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3 || st2.countTokens() == 2) { - st2.nextToken(); - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 2 || s1.length == 3) { + String[] s2 = s1[1].split(DELIMITER_INTRA); + if (s2.length == 3 || s2.length == 2) { + return s2[1]; } } } @@ -267,14 +259,11 @@ public class NamingConventionUtil { // after first occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA - StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); - if (st1.countTokens() == 2 || st1.countTokens() == 3) { - st1.nextToken(); - StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); - if (st2.countTokens() == 3) { - st2.nextToken(); - st2.nextToken(); - return st2.nextToken(); + String[] s1 = conventionName.split(DELIMITER_EXTRA); + if (s1.length == 2 || s1.length == 3) { + String[] s2 = s1[1].split(DELIMITER_INTRA); + if (s2.length == 3) { + return s2[2]; } } }