From 85595c7fa17e056f4dd664fb7e01d6940e1c5d8e Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Wed, 13 Apr 2022 16:17:52 +0200 Subject: complete test for v3 fcb elements fixes on high level data mappings --- .../barcode/ticket/api/utils/UicEncoderUtils.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java') diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java b/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java index 73f96f1..f5eb15c 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java @@ -329,6 +329,49 @@ public class UicEncoderUtils { } } + + public static Long getRestrictedNum(String text, int min, int max) { + + if (text == null || text.length() == 0) { + return null; + } + + Long i; + try { + i = Long.parseLong(text); + } catch (NumberFormatException e) { + return null; + } + if (i < min || i > max) { + return null; + } + return i; + + } + + public static String getIA5RestrictedNonNum(String text, int min, int max) throws EncodingFormatException { + if (text == null || text.length() == 0) { + return null; + } + + for (int i = 0; i < text.length(); i++){ + int index = text.charAt(i); + if (index < 0 || index > 127) { + throw new EncodingFormatException("Wrong Characters in IA5 String encoding"); + } + } + + try { + long l = Long.parseLong(text); + if (l < min || l > max) { + return text; + } else { + return null; + } + } catch (NumberFormatException e) { + return text; + } + } /** * Gets the restricted int. @@ -511,4 +554,6 @@ public class UicEncoderUtils { } + + } -- cgit v1.2.3