diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
commit | f1a08e7fb82e813ce6985460cc2606fc7b19ae13 (patch) | |
tree | 5b68ec0289b228cef09420fc985043ff33105951 /src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java | |
parent | ssb non-standard signature encoding covered (decode only) (diff) | |
download | UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.gz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.bz2 UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.lz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.xz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.zst UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.zip |
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java')
-rw-r--r-- | src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java b/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java index 1b2f6e7..7751ef6 100644 --- a/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java @@ -2,6 +2,7 @@ package org.uic.barcode.ssbFrame; import org.uic.barcode.asn1.uper.BitBuffer; import org.uic.barcode.asn1.uper.ByteBitBuffer; +import org.uic.barcode.ticket.EncodingFormatException; public class SsbGroup extends SsbCommonTicketPart { @@ -52,7 +53,7 @@ public class SsbGroup extends SsbCommonTicketPart { } @Override - protected int encodeContent(byte[] bytes, int offset) { + protected int encodeContent(byte[] bytes, int offset) throws EncodingFormatException { offset = offset + encodeCommonPart(bytes, offset); @@ -61,23 +62,41 @@ public class SsbGroup extends SsbCommonTicketPart { bits.put(offset, isReturnJourney); offset = offset++; + if (firstDayOfValidity < 0 || firstDayOfValidity > 511) { + throw new EncodingFormatException("SSB first day of validity too big"); + } bits.putInteger(offset, 9, firstDayOfValidity); offset = offset + 9; + if (lastDayOfValidity < 0 || lastDayOfValidity > 511) { + throw new EncodingFormatException("SSB last day of validity too big"); + } bits.putInteger(offset, 9, lastDayOfValidity); offset = offset + 9; offset = stations.encode(offset, bytes); + if (groupName.length() > 12) { + throw new EncodingFormatException("SSB group name too big"); + } bits.putChar6String(offset, 72,groupName); offset = offset + 72; + if (counterMarkNumber < 0 || counterMarkNumber > 246) { + throw new EncodingFormatException("SSB number of countermark too big"); + } bits.putInteger(offset, 9,counterMarkNumber); offset = offset + 9; + if (infoCode < 0 || infoCode > 9999) { + throw new EncodingFormatException("SSB info code too big"); + } bits.putInteger(offset, 14, infoCode); offset = offset + 14; + if (text.length() > 24) { + throw new EncodingFormatException("SSB text too big"); + } bits.putChar6String(offset, 144, text); offset = offset + 144; |