From 8770b99fdb6f47dea7b1f598633407e67b22572f Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Thu, 14 Apr 2022 15:09:45 +0200 Subject: - improved encoding of numerical values outside the allowed range - additional unit tests - fixes in the unused version 2 of FCB --- .../uic/barcode/ticket/api/utils/NumWrapper.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java (limited to 'src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java') diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java b/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java new file mode 100644 index 0000000..2adcdf2 --- /dev/null +++ b/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java @@ -0,0 +1,36 @@ +package org.uic.barcode.ticket.api.utils; + +import org.uic.barcode.ticket.EncodingFormatException; + +public class NumWrapper { + + private String ia5string = null; + private Long number = null; + + public NumWrapper(String string, int min, int max) throws EncodingFormatException { + + + if (string == null || string.isEmpty()) { + return; + } + + ia5string = UicEncoderUtils.getIA5RestrictedNonNum (string,min,max); + if (ia5string == null || ia5string.length() == 0) { + number = UicEncoderUtils.getRestrictedNum (string,min,max); + } + if (ia5string != null && ia5string.length() == 0) { + ia5string = null; + } + return; + + } + + public String getString() { + return ia5string; + } + + public Long getNumber() { + return number; + } + +} -- cgit v1.2.3