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 16:17:52 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-13 16:17:52 +0200
commit85595c7fa17e056f4dd664fb7e01d6940e1c5d8e (patch)
tree648ebffa218ae0fa231c26043be20987f0e04d1a /src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
parenttest on car carriage (diff)
downloadUIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar.gz
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar.bz2
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar.lz
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar.xz
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.tar.zst
UIC-barcode-85595c7fa17e056f4dd664fb7e01d6940e1c5d8e.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 {
}
+
+
}