summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-02-10 14:29:44 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-02-10 14:29:44 +0100
commit51da5b4938b7acb2ce75b4a1d35f5fc3115276cc (patch)
tree30a1e5ac336e188b0762cc757600d318ae8b5333 /src/main/java/org/uic/barcode
parentnew exception for wrong identifiers in U_HEAD (diff)
downloadUIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar.gz
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar.bz2
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar.lz
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar.xz
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.tar.zst
UIC-barcode-51da5b4938b7acb2ce75b4a1d35f5fc3115276cc.zip
Diffstat (limited to 'src/main/java/org/uic/barcode')
-rw-r--r--src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
index fdef178..31a664b 100644
--- a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
+++ b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
@@ -222,7 +222,15 @@ public class UHEADDataRecord extends DataRecord{
protected void encodeContent() throws IOException, EncodingFormatException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-
+
+ if (this.issuer == null || this.issuer.length() < 1) {
+ throw new EncodingFormatException("Issuer in U_HEAD missing");
+ }
+ if (this.issuer.length() > 4) {
+ throw new EncodingFormatException("Issuer in U_HEAD too long (max 4 bytes)");
+ }
+
+
String issuerElement = String.format("%4s", this.issuer);
if (this.identifier == null || this.identifier.length() < 1) {
@@ -230,7 +238,7 @@ public class UHEADDataRecord extends DataRecord{
}
if (this.identifier.length() > 20) {
- throw new EncodingFormatException("Identifier in U_HEAD too long (max. 20 byte)");
+ throw new EncodingFormatException("Identifier in U_HEAD too long (max. 20 bytes)");
}
@@ -258,12 +266,20 @@ public class UHEADDataRecord extends DataRecord{
String language1 = null;
String language2 = null;
if (this.language != null) {
- language1 = String.format("%2s" ,this.language);
+ if (this.language.length() > 2) {
+ language1 = String.format("%2s" ,this.language.substring(0, 2));
+ } else {
+ language1 = String.format("%2s" ,this.language);
+ }
} else {
language1 = " ";
}
if (this.additionalLanguage != null) {
- language2 = String.format("%2s" ,this.additionalLanguage);
+ if (this.additionalLanguage.length() > 2) {
+ language2 = String.format("%2s" ,this.additionalLanguage.substring(0, 2));
+ } else {
+ language2 = String.format("%2s" ,this.additionalLanguage);
+ }
} else {
language2 = " ";
}