summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-13 17:57:16 +0200
committerGitHub <noreply@github.com>2022-04-13 17:57:16 +0200
commit7a5f15e2b958dca771b83594669401be2b84f2b6 (patch)
treed96492a7b1958f9822cd994c86d0b0a9f3c6c59f /src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
parentMerge pull request #45 from UnionInternationalCheminsdeFer/1.3.1 (diff)
parentunit test for fcb version 1 including all elements (diff)
downloadUIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.gz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.bz2
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.lz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.xz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.zst
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java')
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java45
1 files changed, 45 insertions, 0 deletions
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 {
}
+
+
}