Skip to content
Snippets Groups Projects
Commit c522e1e3 authored by Lars Johansson's avatar Lars Johansson
Browse files

Refactor to use String.split instead of StringTokenizer

parent 12bd26ef
No related branches found
No related tags found
No related merge requests found
Pipeline #124636 passed
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package org.openepics.names.util; package org.openepics.names.util;
import java.util.Arrays; import java.util.Arrays;
import java.util.StringTokenizer;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openepics.names.repository.model.Discipline; import org.openepics.names.repository.model.Discipline;
...@@ -138,11 +137,11 @@ public class NamingConventionUtil { ...@@ -138,11 +137,11 @@ public class NamingConventionUtil {
// system structure // system structure
// before first occurrence of DELIMITER_EXTRA // before first occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 1 || s1.length == 2 || s1.length == 3) {
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); String[] s2 = s1[0].split(DELIMITER_INTRA);
if (st2.countTokens() == 3) { if (s2.length == 3) {
return st2.nextToken(); return s2[0];
} }
} }
} }
...@@ -161,14 +160,13 @@ public class NamingConventionUtil { ...@@ -161,14 +160,13 @@ public class NamingConventionUtil {
// system structure // system structure
// before first occurrence of DELIMITER_EXTRA // before first occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 1 || s1.length == 2 || s1.length == 3) {
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); String[] s2 = s1[0].split(DELIMITER_INTRA);
if (st2.countTokens() == 3) { if (s2.length == 3) {
st2.nextToken(); return s2[1];
return st2.nextToken(); } else if (s2.length == 2 || s2.length == 1) {
} else if (st2.countTokens() == 2 || st2.countTokens() == 1) { return s2[0];
return st2.nextToken();
} }
} }
} }
...@@ -187,16 +185,13 @@ public class NamingConventionUtil { ...@@ -187,16 +185,13 @@ public class NamingConventionUtil {
// system structure // system structure
// before first occurrence of DELIMITER_EXTRA // before first occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 1 || st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 1 || s1.length == 2 || s1.length == 3) {
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); String[] s2 = s1[0].split(DELIMITER_INTRA);
if (st2.countTokens() == 3) { if (s2.length == 3) {
st2.nextToken(); return s2[2];
st2.nextToken(); } else if (s2.length == 2) {
return st2.nextToken(); return s2[1];
} else if (st2.countTokens() == 2) {
st2.nextToken();
return st2.nextToken();
} }
} }
} }
...@@ -216,12 +211,11 @@ public class NamingConventionUtil { ...@@ -216,12 +211,11 @@ public class NamingConventionUtil {
// after first occurrence of DELIMITER_EXTRA // after first occurrence of DELIMITER_EXTRA
// before possible second occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 2 || s1.length == 3) {
st1.nextToken(); String[] s2 = s1[1].split(DELIMITER_INTRA);
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); if (s2.length == 3 || s2.length == 2) {
if (st2.countTokens() == 3 || st2.countTokens() == 2) { return s2[0];
return st2.nextToken();
} }
} }
} }
...@@ -241,13 +235,11 @@ public class NamingConventionUtil { ...@@ -241,13 +235,11 @@ public class NamingConventionUtil {
// after first occurrence of DELIMITER_EXTRA // after first occurrence of DELIMITER_EXTRA
// before possible second occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 2 || s1.length == 3) {
st1.nextToken(); String[] s2 = s1[1].split(DELIMITER_INTRA);
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); if (s2.length == 3 || s2.length == 2) {
if (st2.countTokens() == 3 || st2.countTokens() == 2) { return s2[1];
st2.nextToken();
return st2.nextToken();
} }
} }
} }
...@@ -267,14 +259,11 @@ public class NamingConventionUtil { ...@@ -267,14 +259,11 @@ public class NamingConventionUtil {
// after first occurrence of DELIMITER_EXTRA // after first occurrence of DELIMITER_EXTRA
// before possible second occurrence of DELIMITER_EXTRA // before possible second occurrence of DELIMITER_EXTRA
StringTokenizer st1 = new StringTokenizer(conventionName, DELIMITER_EXTRA, false); String[] s1 = conventionName.split(DELIMITER_EXTRA);
if (st1.countTokens() == 2 || st1.countTokens() == 3) { if (s1.length == 2 || s1.length == 3) {
st1.nextToken(); String[] s2 = s1[1].split(DELIMITER_INTRA);
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), DELIMITER_INTRA, false); if (s2.length == 3) {
if (st2.countTokens() == 3) { return s2[2];
st2.nextToken();
st2.nextToken();
return st2.nextToken();
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment