From fc6a4042f7fca1828f0b8e267cfd660e6fe1d40a Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Tue, 22 Nov 2022 14:04:27 +0100 Subject: support for SSB barcodes SSB frame implenmentation including decoding, encoding, signing and verification --- .../uic/barcode/ssbFrame/SsbNonReservation.java | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java') diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java b/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java new file mode 100644 index 0000000..e96e853 --- /dev/null +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java @@ -0,0 +1,114 @@ +package org.uic.barcode.ssbFrame; + +import org.uic.barcode.asn1.uper.BitBuffer; +import org.uic.barcode.asn1.uper.ByteBitBuffer; + +public class SsbNonReservation extends SsbCommonTicketPart { + + protected int firstDayOfValidity = 0; + protected int lastDayOfValidity = 0; + protected boolean isReturnJourney = false; + private int infoCode = 0; + private String text = null; + private SsbStations stations = new SsbStations(); + + + @Override + protected void decodeContent(byte[] bytes) { + + int offset = decodeCommonPart(bytes); + + BitBuffer bits = new ByteBitBuffer(bytes); + + isReturnJourney = bits.get(offset); + offset = offset++; + + firstDayOfValidity = bits.getInteger(offset, 9); + offset = offset + 9; + + lastDayOfValidity = bits.getInteger(offset, 9); + offset = offset + 9; + + offset = stations.decode(offset, bytes); + + infoCode = bits.getInteger(offset, 14); + offset = offset + 14; + + text = bits.getChar6String(offset, 222); + offset = offset + 222; + + } + + @Override + protected void encodeContent(byte[] bytes) { + + int offset = encodeCommonPart(bytes); + + BitBuffer bits = new ByteBitBuffer(bytes); + + bits.put(offset, isReturnJourney); + offset = offset++; + + bits.putInteger(offset, 9, firstDayOfValidity); + offset = offset + 9; + + bits.putInteger(offset, 9, lastDayOfValidity); + offset = offset + 9; + + offset = stations.decode(offset, bytes); + + bits.putInteger(offset, 14, infoCode); + offset = offset + 14; + + bits.putChar6String(offset, 222, text); + offset = offset + 222; + + } + + public int getFirstDayOfValidity() { + return firstDayOfValidity; + } + + public void setFirstDayOfValidity(int firstDayOfValidity) { + this.firstDayOfValidity = firstDayOfValidity; + } + + public int getLastDayOfValidity() { + return lastDayOfValidity; + } + + public void setLastDayOfValidity(int lastDayOfValidity) { + this.lastDayOfValidity = lastDayOfValidity; + } + + public boolean isReturnJourney() { + return isReturnJourney; + } + + public void setReturnJourney(boolean isReturnJourney) { + this.isReturnJourney = isReturnJourney; + } + + public int getInfoCode() { + return infoCode; + } + + public void setInfoCode(int infoCode) { + this.infoCode = infoCode; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public SsbStations getStations() { + return stations; + } + + + +} -- cgit v1.2.3